How do I change the overlayMapType opacity after I added to the map?
var imgTypeOptions = {
getTileUrl: function (coord, zoom) {
return "myTile/" + f + ".png";
},
tileSize: new google.maps.Size(256, 256),
name: "Imagen",
opacity: .5 //This is Ok, the first time set the opacity
//but i want to change the opacity later
};
...
var imgMapType = new google.maps.ImageMapType(imgTypeOptions);
...
map.overlayMapTypes.insertAt(0, imgMapType);
I want to be able to click a link "25%" and set the opacity of the added layer to 25%.
In 3.28 you have to use the getter. Please try the following code:
map.overlayMapTypes.getAt(0).setOpacity(0.25)
Have a look at the ImageMapType api documentation:
https://developers.google.com/maps/documentation/javascript/reference#ImageMapType
Something like this should work.
map.overlayMapTypes[0].setOpacity(.25)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With