Google Maps是否支持KML地区? [英] Does Google Maps support KML regions?

查看:68
本文介绍了Google Maps是否支持KML地区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像Google Earth一样,Google Maps是否支持KML区域?

Google在此处提供了不错的区域说明/教程:

https://developers.google.com/kml/documentation/regions

专门提及Google Earth,但未提及Google Maps.

根据 https://developers.google.com/kml/documentation/kmlelementsinmaps Google Maps DOES支持KML地区,但 https://developers.google.com/kml/documentation/mapsSupport 没有明确提及它们.

在Google地图上的kml文件中缩放级别 在这个问题上也模棱两可.

我创建了自己的测试KML文件(从Google几乎逐字盗窃):

<?xml version="1.0" encoding="UTF-8"?>  
<kml xmlns="http://www.opengis.net/kml/2.2">  
  <Document>  
    <name>Flat Region</name>  
    <Region>  
      <LatLonAltBox>  
        <north>37.430419921875</north>  
        <south>37.41943359375</south>  
        <east>-122.080078125</east>  
        <west>-122.091064453125</west>  
      </LatLonAltBox>  
      <Lod>  
        <minLodPixels>128</minLodPixels>  
      </Lod>  
    </Region>  
    <GroundOverlay>  
      <name>Mountain View DOQQ</name>  
      <Icon>  
        <href>http://data.bcinfo3.barrycarter.info/graphpaper.gif</href>  
      </Icon>  
      <LatLonBox>  
        <north>37.430419921875</north>  
        <south>37.41943359375</south>  
        <east>-122.080078125</east>  
        <west>-122.091064453125</west>  
      </LatLonBox>  
    </GroundOverlay>  
  </Document>  
</kml>  

您可以在这里看到它:

如果是,这是否可以证明Google Maps不支持KML地区?

还是我误会了什么?

解决方案

我无法为您提供完整的解决方案,但大约一年前,我尝试使用地图中的区域"来避免点拥挤(在SO上提出类似问题) ),据我了解,KmlLayer不会识别区域,而只会加载所有内容.我唯一可以找到的参考是论坛帖子,例如: http://code.google.com/p/gmaps-api-issues/issues/detail?id=3142

那是我当时的理解,可以通过使用API​​在javascript中添加叠加层和区域来实现-我只是看了一下,却找不到很好的示例(或任何示例)

在我看来,编写自定义叠加层和重写绘图功能应该很容易,以便在缩放地图时显示/隐藏之前考虑叠加层的大小:https://developers.google.com/kml/documentation/regions

which mentions Google Earth specifically, but not Google Maps.

According to https://developers.google.com/kml/documentation/kmlelementsinmaps Google Maps DOES support KML regions, but https://developers.google.com/kml/documentation/mapsSupport doesn't mention them explicitly.

Zoom levels in kml files on google maps is also ambigious on the issue.

I created my own test KML file (stolen almost verbatim from google):

<?xml version="1.0" encoding="UTF-8"?>  
<kml xmlns="http://www.opengis.net/kml/2.2">  
  <Document>  
    <name>Flat Region</name>  
    <Region>  
      <LatLonAltBox>  
        <north>37.430419921875</north>  
        <south>37.41943359375</south>  
        <east>-122.080078125</east>  
        <west>-122.091064453125</west>  
      </LatLonAltBox>  
      <Lod>  
        <minLodPixels>128</minLodPixels>  
      </Lod>  
    </Region>  
    <GroundOverlay>  
      <name>Mountain View DOQQ</name>  
      <Icon>  
        <href>http://data.bcinfo3.barrycarter.info/graphpaper.gif</href>  
      </Icon>  
      <LatLonBox>  
        <north>37.430419921875</north>  
        <south>37.41943359375</south>  
        <east>-122.080078125</east>  
        <west>-122.091064453125</west>  
      </LatLonBox>  
    </GroundOverlay>  
  </Document>  
</kml>  

You can see it here:

http://test.bcinfo3.barrycarter.info/bc-image-overlay.pl?url=regiontest.kml&center=37.425,-122.085&zoom=15

As you zoom out, the image remains visible (albeit as a white square) even when it's only a few pixels on each side.

Does the "minLodPixels" setting of 128 in the KML file mean it should stop being visible once it takes up fewer than 128 pixels?

If so, would this prove Google Maps does NOT support KML regions?

Or am I misunderstanding something?

解决方案

I can't give you a completed solution but I tried to avoid overcrowding of my points using Regions in maps about a year ago (asked a similar question on SO) and it was my understanding that KmlLayer would not recognize regions and instead just load everything. The only reference I can find to this are forum posts though e.g.: http://code.google.com/p/gmaps-api-issues/issues/detail?id=3142

That said it was my understanding at the time that this could be achieved by using the API to add the overlays and regions in javascript - I just looked and I can not find a good example of this (or any example at all).

It does seem to me though that it should be pretty easy to write a custom Overlay and override the draw function to take account of the size of the overlay before showing / hiding as the map is zoomed: https://developers.google.com/maps/documentation/javascript/overlays#Drawing

Which is the path I intend on taking when we implement some of the features we need around it - but does not solve having this implemented directly from the KML. What is interesting is you link to the documentation indicating it is supported.

这篇关于Google Maps是否支持KML地区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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