ArcMap 导出地图以用于 Google Maps API v3
ArcMap Export maps for use in Google Maps API v3
我使用 ArcMap 10.2 程序,我在其中创建了几张使用图层创建的地图。我需要导入这些地图以便在 Google Maps API v3 中使用。我导出了 .kmz 和 .json 等,但是当导入到 Google API 时看不到图层。这是一个代码示例:
var spain = new google.maps.LatLng(40.3964129438718, -3.7129999999999654);
var mapa = new google.maps.Map(document.getElementById("mapaSigaus"), {
center: spain,
zoom: 6
});
var kmzLayer = new google.maps.KmlLayer('URL/ESP_adm4.kmz');
kmzLayer.setMap(mapa);
我做错了什么或遗漏了什么?
尝试在 KmlLayerOptions 对象中定义 url,如下所示:
var kmzLayer = new google.maps.KmlLayer({url:'URL/ESP_adm4.kmz'});
如果您愿意,也可以用这种方式分配地图:
var kmzLayer = new google.maps.KmlLayer({
url:'URL/ESP_adm4.kmz',
map: mapa
});
- KMZ url 需要完整 URL:
http://www.geocodezip.com/geoxml3_test/kmz/ESP_adm4.kmz
(a relative URL returns a KmlStatus of INVALID_REQUEST
)
- KMZ 文件需要满足 Google 地图 Javascript API KmlLayer 渲染器的限制。来自 the documentation:),它们是:
Size and Complexity Restrictions for KML Rendering in Google Maps
Google Maps currently has specific limitations to the size and complexity of loaded KML files. Below is a summary of the current limits:
Note: these limits are temporary and are subject to change at any time.
Maximum fetched file size (raw KML, raw GeoRSS, or compressed KMZ) 3MB
Maximum uncompressed KML file size 10MB
Maximum number of Network Links 10
Maximum number of total document-wide features 1,000
您没有为您的 KMZ 文件提供 link,而是基于 gadm.org, it is probably ~5 MB compressed KMZ, which is too big (it returns a KmlStatus of DOCUMENT_TOO_LARGE
for me 处的同名 KMZ 文件副本。
如果文件是从您的本地域提供的,您可以使用 geoxml3 to render it, but may have performance issues (geoxml3 decompresses it to KML, then renders that KML as native Google Maps Javascript API v3 objects),这就是 google 限制它们将呈现的文件大小的原因。
您是要从您的文件系统还是从 Web url 加载文件?
使用 google.maps.KmlLayer 添加 kmz 会调用名为 KmlOverlayService 的服务,该服务会解压缩 kmz 并将其 returns 返回给您 - 这不适用于本地文件。
我尝试直接从 kmz you linked, and the load time via the KmlOverlayService was over 10s and failed to add to map. However, when I made a copy of your kmz in my dropbox public folder 添加您的文件,然后添加到地图:
var kmzLayer = new google.maps.KmlLayer({
url:'https://dl.dropboxusercontent.com/u/5097876/Minimo.kmz',
map: mapa
});
我按预期显示了 kmz 图层。
(请注意,在这种情况下,您在没有 KmlLayerOptions 对象的情况下添加 kmz 的原始方法也可以正常工作。)
我使用 ArcMap 10.2 程序,我在其中创建了几张使用图层创建的地图。我需要导入这些地图以便在 Google Maps API v3 中使用。我导出了 .kmz 和 .json 等,但是当导入到 Google API 时看不到图层。这是一个代码示例:
var spain = new google.maps.LatLng(40.3964129438718, -3.7129999999999654);
var mapa = new google.maps.Map(document.getElementById("mapaSigaus"), {
center: spain,
zoom: 6
});
var kmzLayer = new google.maps.KmlLayer('URL/ESP_adm4.kmz');
kmzLayer.setMap(mapa);
我做错了什么或遗漏了什么?
尝试在 KmlLayerOptions 对象中定义 url,如下所示:
var kmzLayer = new google.maps.KmlLayer({url:'URL/ESP_adm4.kmz'});
如果您愿意,也可以用这种方式分配地图:
var kmzLayer = new google.maps.KmlLayer({
url:'URL/ESP_adm4.kmz',
map: mapa
});
- KMZ url 需要完整 URL:
http://www.geocodezip.com/geoxml3_test/kmz/ESP_adm4.kmz
(a relative URL returns a KmlStatus of INVALID_REQUEST
)
- KMZ 文件需要满足 Google 地图 Javascript API KmlLayer 渲染器的限制。来自 the documentation:),它们是:
Size and Complexity Restrictions for KML Rendering in Google Maps
Google Maps currently has specific limitations to the size and complexity of loaded KML files. Below is a summary of the current limits:
Note: these limits are temporary and are subject to change at any time.
Maximum fetched file size (raw KML, raw GeoRSS, or compressed KMZ) 3MB
Maximum uncompressed KML file size 10MB
Maximum number of Network Links 10
Maximum number of total document-wide features 1,000
您没有为您的 KMZ 文件提供 link,而是基于 gadm.org, it is probably ~5 MB compressed KMZ, which is too big (it returns a KmlStatus of DOCUMENT_TOO_LARGE
for me 处的同名 KMZ 文件副本。
如果文件是从您的本地域提供的,您可以使用 geoxml3 to render it, but may have performance issues (geoxml3 decompresses it to KML, then renders that KML as native Google Maps Javascript API v3 objects),这就是 google 限制它们将呈现的文件大小的原因。
您是要从您的文件系统还是从 Web url 加载文件? 使用 google.maps.KmlLayer 添加 kmz 会调用名为 KmlOverlayService 的服务,该服务会解压缩 kmz 并将其 returns 返回给您 - 这不适用于本地文件。
我尝试直接从 kmz you linked, and the load time via the KmlOverlayService was over 10s and failed to add to map. However, when I made a copy of your kmz in my dropbox public folder 添加您的文件,然后添加到地图:
var kmzLayer = new google.maps.KmlLayer({
url:'https://dl.dropboxusercontent.com/u/5097876/Minimo.kmz',
map: mapa
});
我按预期显示了 kmz 图层。
(请注意,在这种情况下,您在没有 KmlLayerOptions 对象的情况下添加 kmz 的原始方法也可以正常工作。)