Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google maps overlay layer

i'm trying to put a layer on top of my google maps to cover it up. There doesn't have to be any interaction with google maps, it's just one layer on top the other.

what i have now:

<div id="map">
   <div id="overlay"></div>
</div>   

in the map div i put my google maps, and the overlay layer has a background as big as the map div, but the google maps keeps putting itself on top.

Anyone an idee what i can do about it?

like image 273
dazz Avatar asked Aug 04 '10 12:08

dazz


People also ask

Can Google Maps do layers?

You can organize your map features with map layers. For example, you can put color-coded restaurants on one layer and coffee shops on another.

How do I overlay a route on Google Maps?

To start drawing your route simply doubleclick on the map to set the starting pinpoint, then continue to click each of the points along the route you wish to follow. You can change the map view to satellite, hybrid or terrain using the selector on the top left corner of the route map.

What are layers used for in Google Maps?

Layers are objects on the map that consist of one or more separate items, but are manipulated as a single unit. Layers generally reflect collections of objects that you add on top of the map to designate a common association.


1 Answers

Google Maps API V3 supports an option called noClear:

If true, do not clear the contents of the Map div.

Use it like:

var myLatlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
  zoom: 8,
  center: myLatlng,
  mapTypeId: google.maps.MapTypeId.ROADMAP,
  noClear: true,
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
    myOptions);

However, semantically it feels better to put the div#overlay as the next sibling of the map div as @Marcelo suggests.

like image 178
ento Avatar answered Nov 07 '22 11:11

ento