需要帮助才能在Google地图上添加多个自定义图层。 我有脚本:
function newMap(id,lon,lat,zoom,mapstart){
var nmap = new GMap2(document.getElementById(id),{backgroundColor: "Silver"});
nmap.addControl(new GLargeMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(8,37)));
nmap.addControl(new GOverviewMapControl());
nmap.addControl(new GScaleControl());
nmap.enableScrollWheelZoom();
nmap.enableContinuousZoom();
var GMapTypeOptions = new Object({minResolution: 9, maxResolution: 18});
var copyCollection = new GCopyrightCollection('');
var copyright = new GCopyright(1, new GLatLngBounds(new GLatLng(-89,-179), new GLatLng(89,179)),0,"<font color=white><B>Demo <a href=http://mysite.com target=_blank><font color=white>mysite.com</font></a><BR>demo <a href=http://www.maps.com target=_blank><font color=white>maps.com</font></a>, <a href=http://www.pobeda-info.by target=_blank><font color=white>pobeda-info.by</font></a></B><BR></font>");
copyCollection.addCopyright(copyright);
var WWIILayer = new GTileLayer(copyCollection, 9,18,{tileUrlTemplate:'http://mymap.com/AerialWWII/Z{Z}/{Y}/{X}.jpg'});
//http://46.182.27.171
var WWIIMap = new GMapType([WWIILayer], new GMercatorProjection(22), "WWII", {});
nmap.addMapType(WWIIMap);
var WWIIHybMap = new GMapType([WWIILayer, G_HYBRID_MAP.getTileLayers()[1]], new GMercatorProjection(22), "Show streets",GMapTypeOptions);
nmap.addMapType(WWIIHybMap);
var hierarchy = new GHierarchicalMapTypeControl();
hierarchy.addRelationship(WWIIMap, WWIIHybMap, false);
if (mapstart==1) {
nmap.setCenter( new GLatLng(lon,lat), zoom, WWIIMap);
} else {
nmap.setCenter( new GLatLng(lon,lat), zoom, G_SATELLITE_MAP);
}
nmap.addControl(hierarchy);
return nmap;
}
使用一层“WWII”工作得很好!需要添加第二个自定义图层“WWII - 2”,也许有人可以帮忙吗?
答案 0 :(得分:0)
这看起来像Google Maps JS v2代码。您是否考虑过将代码升级到v3? https://developers.google.com/maps/articles/v2tov3
一旦你进入v3,更多的示例代码将有意义,人们将更愿意帮助你。