Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change opacity of overlaymaptypes?

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%.

like image 766
Rolando Avatar asked Apr 09 '13 21:04

Rolando


2 Answers

In 3.28 you have to use the getter. Please try the following code:

map.overlayMapTypes.getAt(0).setOpacity(0.25)
like image 119
Alex Avatar answered Oct 05 '22 22:10

Alex


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) 
like image 32
Jonathan Palumbo Avatar answered Oct 05 '22 22:10

Jonathan Palumbo