基于 ImageMapType 的 Google 地图 V3 KML 图层
我通过 MapTiler 创建了一个相当小的自定义地图,并且使用 GMap 渲染它非常容易。所需的几行代码的基础知识如下。
我也有一个可爱的小 KML 图层,它渲染得很好。
然而......在我的一生中,我无法让两个图层一起显示。一旦指示 KML 进行渲染,自定义地图图层就会消失。 Firebug 甚至告诉我,甚至没有要求我的自定义图块!理想情况下,我需要在自定义地图图层上使用 KML 图层。它将显示一些英国地标的位置。
在我的脑海深处,我正在考虑投影类型和冲突,但是当两个图层分别在底图上正确渲染时,我真的一无所知。
谁能给我有关 Google 地图 V3 中自定义地图类型上的 KML 图层的建议?
谢谢
var MyCustomMapType = new google.maps.ImageMapType({
getTileUrl: function(tile, zoom) {
return "/static/images/maps/uk/" + zoom+"/"+tile.x+"/"+ tile.y +".png";
},
tileSize: new google.maps.Size(256, 256),
});
function init(){
var mapOpts = {
zoom: 6,
center: new google.maps.LatLng(53.94315470224928, -3.515625),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), mapOpts);
map.overlayMapTypes.insertAt(0, MyCustomMapType);
var cathedrals = new google.maps.KmlLayer('http://pointing_at_my/kml/');
// as soon as this executes, ImageMapType layer disappears
cathedrals.setMap(map);
}
I have a pretty little custom map created through MapTiler and it was dead easy to get it to render with GMaps. The basics of the few lines of code needed are below.
I have a lovely little KML layer too which renders fine.
However.... for the life of me I can't get both layers to display together. As soon as the KML is instructed to render, the custom map layer disappears. Firebug even tells me that my custom tiles are not even requested! Ideally I need the KML layer over my custom map layer. It's going to show where a few UK landmarks are located.
At the back of my mind I'm thinking projection types and conflicts, but when both layers render correctly on the base map individually, I really am left in the dark.
Can anyone give me advice on KML layers over Custom Map Types in Google Maps V3?
Thank you
var MyCustomMapType = new google.maps.ImageMapType({
getTileUrl: function(tile, zoom) {
return "/static/images/maps/uk/" + zoom+"/"+tile.x+"/"+ tile.y +".png";
},
tileSize: new google.maps.Size(256, 256),
});
function init(){
var mapOpts = {
zoom: 6,
center: new google.maps.LatLng(53.94315470224928, -3.515625),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), mapOpts);
map.overlayMapTypes.insertAt(0, MyCustomMapType);
var cathedrals = new google.maps.KmlLayer('http://pointing_at_my/kml/');
// as soon as this executes, ImageMapType layer disappears
cathedrals.setMap(map);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决了。只是别当个白痴。
Solved. Just don't be an idiot.