[OpenLayers-Users] Map covers other layers

Guyren Howe guyren at mac.com
Thu Aug 12 19:08:45 EDT 2010


I'm using Google Maps v2 API and getting just a map, no controls or markers.

When I trace the jscript, I can see that it's drawing the markers and controls, then drawing the map on top of them.

Doesn't seem to matter what order I add the layers to the map.

And of course, trying to search on anything related to "layer" on the OpenLayers website (or google) is an act of futility.

Here is the javascript code:

function initialize_map(){
	var map = new OpenLayers.Map("map_canvas");
    
	var markers = new OpenLayers.Layer.Markers("Markers");
	map.addLayer(markers);

    var gphy = new OpenLayers.Layer.Google(
        "Google Physical",
        {type: G_PHYSICAL_MAP}
    );
    var gmap = new OpenLayers.Layer.Google(
        "Google Streets", // the default
        {numZoomLevels: 20}
    );
    var ghyb = new OpenLayers.Layer.Google(
        "Google Hybrid",
        {type: G_HYBRID_MAP, numZoomLevels: 20}
    );
    var gsat = new OpenLayers.Layer.Google(
        "Google Satellite",
        {type: G_SATELLITE_MAP, numZoomLevels: 22}
    );


    map.addLayers([gphy, gmap, ghyb, gsat]);

    map.addControl(new OpenLayers.Control.LayerSwitcher());
	
    var size = new OpenLayers.Size(21,34);
    var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
	var l, m;
	
	with_pin_details(function(pin, lat, long, marker, ts, url) {
		l = new OpenLayers.LonLat(long, lat);
		m = new OpenLayers.Marker(l, new OpenLayers.Icon(marker, size, offset));
		markers.addMarker(m);
		f = function(){
			showInfoWindow(map, m, ts, url);
		};
		m.events.register("mousedown", m, f);
		pin.onclick = f;
	});
    map.zoomToExtent(markers.getDataExtent());
}



More information about the Users mailing list