Google Maps API + Google Maps Engine /我的地图 [英] Google Maps API + Google Maps Engine / My Maps

查看:116
本文介绍了Google Maps API + Google Maps Engine /我的地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Google地图引擎将自定义地图的图层和形状嵌入到我的网页中,但它将停止使用,替代品是Google My Maps,它很轻便,但似乎满足我的需求。

现在回到我的问题。我正在使用Google地图API在我的网页上显示地图,并且我也有来自我的地图的地图的嵌入代码,我想将它们合并。因此,我希望加载Google Maps API并显示我喜欢的任何区域,添加标记和所有内容,然后在该地图上(或下方)显示来自我的地图中特定地图的图层和形状。



就像我说的,我有嵌入代码,它自己可以工作,mapId的格式是abcdefgh.abcdefgh。

现在,在Google Maps API中,有一个(已弃用的)MapsEngineLayer功能可以按ID加载特定的Maps Engine图层,但无法在我的地图中找到具有特定图层ID的方法发现,再加上我想要一个mapID的所有图层,但该函数需要一个layerId或LayerKey。

所以,有没有办法从我的地图到Google Maps API的正常显示中? 您也可以下载这样的地图,例如KML,下载URL就像



https://www.google.com/maps/d/kml?mid=themymaps.mapid



没有记录,但目前它适用于我当我使用这个URL创建一个KmlLayer时(它应该工作,只要他们不修改下载过程)。


$ b 示例(原始地图

  function initialize(){var map = new google.maps.Map(document.getElementById('map-canvas'),{zoom:0,center :new google.maps.LatLng(0,0)}),myMapsId ='z4jtZiEBVczE.kp_M0KHEIung';新的google.maps .KmlLayer({map:map,url:'https://www.google.com/maps/d/kml?mid='+ myMapsId});} google.maps.event.addDomListener(window, 'load',initialize);  

  html,body,# map-canvas {height:100%; margin:0px; < script src =https://   


I've used Google Maps Engine to embed customized maps with layers and shapes into my web page, but it is going to be discontinued, and the replacement is Google My Maps, which is lightweight, but seems to serve my needs.

Now to my question. I am using Google Maps API to display a map on my web page, and I also have the embed code for a map from My Maps, and I want to combine them. So I want to load Google Maps API and display whatever area I like, adding markers and everything, and then on top of that (or under that) display the layers and shapes from a specific map in My Maps.

Like I said, I have the embed code, which works on its own, and the mapId is in the format "abcdefgh.abcdefgh".

Now, looking in the Google Maps API, there is a (deprecated) "MapsEngineLayer" function to load a specific Maps Engine Layer by ID, but there is no way to find out a specific layer ID in My Maps that I have found, plus I want all the layers of one mapID, but that function requires a layerId or LayerKey.

So, is there a way to include a map from "my maps" into the normal display from the Google Maps API?

解决方案

You may also download such a map as KML, the download-URL is something like

https://www.google.com/maps/d/kml?mid=themymaps.mapid

It's not documented, but currently it works for me when I use this URL to create a KmlLayer(it should work as long they didn't modify the download-procedure).

Example(original map)

function initialize() {

  var map = new google.maps.Map(document.getElementById('map-canvas'), {
      zoom: 0,
      center: new google.maps.LatLng(0, 0)
    }),

    myMapsId = 'z4jtZiEBVczE.kp_M0KHEIung';
  new google.maps
    .KmlLayer({
      map: map,
      url: 'https://www.google.com/maps/d/kml?mid=' + myMapsId
    });
}

google.maps.event.addDomListener(window, 'load', initialize);

  html,
  body,
  #map-canvas {
    height: 100%;
    margin: 0px;
    padding: 0px
  }

<script src="https://maps.googleapis.com/maps/api/js?v=3"></script>
<div id="map-canvas"></div>

这篇关于Google Maps API + Google Maps Engine /我的地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆