本文介绍了在谷歌地图中导入 myMaps 数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个网络/移动应用程序,该应用程序处理路线以为现有地图应用程序提供附加值.我想知道是否有办法从谷歌的 myMaps(A、B、C 等点以及路线......或最低限度的点)导入数据.如果是,怎么办?
I'm developing a web/mobile application that processes itineraries to deliver added value to the existing mapping applications.I'm wondering if there is a way to import data from google's myMaps (the points A, B, C, etc.. as well as the routes... or just the points minimally). If so, how?
推荐答案
一种选择是从 Google myMaps 导出 KML(作为网络链接或直接),然后使用 Google Maps Javascript API v3 KmlLayer
One option is to export the KML from Google myMaps (either as a network link or directly), then display that using the Google Maps Javascript API v3 KmlLayer
代码片段:
var map;
function initialize() {
var map = new google.maps.Map(
document.getElementById("map_canvas"), {
center: new google.maps.LatLng(37.4419, -122.1419),
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var kmlLayer = new google.maps.KmlLayer({
url: "http://www.google.com/maps/d/kml?forcekml=1&mid=zNPjLbo835mE.k3TvWfqGG-AU",
map: map
});
google.maps.event.addListener(kmlLayer, 'status_changed', function() {
document.getElementById('status').innerHTML = kmlLayer.getStatus();
});
}
google.maps.event.addDomListener(window, "load", initialize);
function showLocation(locate) {
for (var i = 0; i < parseInt(locate.length); i++) {
var address = locate[i];
var geocoder = new google.maps.Geocoder();
geocoder.geocode({
address: address
}, addAddressToMap);
}
}
var disp_title = '.$array1.';
var gj = 0;
function addAddressToMap(response) {
place = response.Placemark[0];
point = new google.maps.LatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);
map.setCenter(point, 7);
var marker1 = createMarker(point, disp_title[gj], response.name);
map.addOverlay(marker1);
gj++;
}
function createMarker(point) {
var marker = new google.maps.Marker({
position: latlng,
map: map,
title: name
});
google.maps.event.addListener(marker, "click", function() {
infoWindow.setContent(html);
infoWindow.open(html + "<br />Location: " + place_name);
});
}
html,
body,
#map_canvas {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px
}
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script>
<div id="status"></div>
<div id="map_canvas" style="border: 2px solid #3872ac;"></div>
这篇关于在谷歌地图中导入 myMaps 数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!