本文介绍了在Google地图中导入myMaps数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个网络/移动应用程序,用于处理行程以向现有的地图应用程序提供附加价值。
我想知道是否有一种方法可以从谷歌的myMaps(点A,B,C等等,以及路线...或最低点)导入数据。如果是这样,怎么做?
解决方案
一个选择是从Google myMaps中导出KML(无论是作为网络链接还是直接)然后使用Google Maps JavaScript API v3
代码段:
//maps.googleapis.com/maps/api/js\"></script><div id =status>< / div>< div id =map_canvasstyle =border:2px solid#3872ac;>< / div>
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?
解决方案
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
code snippet:
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"></script> <div id="status"></div> <div id="map_canvas" style="border: 2px solid #3872ac;"></div>
这篇关于在Google地图中导入myMaps数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!