[英]Import local (on disk) KML file with Googlemaps js in web app
I am developing a web application with a Google maps JS. 我正在使用Google maps JS开发Web应用程序。 The GoogleMaps API allows you to import kml files from a server. GoogleMaps API允许您从服务器导入kml文件。
var kmlLayer = new google.maps.KmlLayer({
url: url_kml_finale,
map: map
});
google.maps.event.addListener(kmlLayer, 'status_changed', function() {...}...
I would like to import a KML file from my hard drive. 我想从硬盘驱动器导入KML文件。 Is that possible? 那可能吗? I did not find a function in the API to parse a kml file. 我在API中找不到解析kml文件的函数。
Thanks in advance. 提前致谢。
This is not possible. 这是不可能的。 google.maps.KmlLayer
elements are rendered server-side on Google's infrastructure so they need to be accessible to the internet. google.maps.KmlLayer
元素在Google基础结构的服务器端呈现,因此它们需要Internet可以访问。
One workaround - you could try to load KML just like a regular XML file and locally parse it and draw the markers, polylines, and polygons yourself. 一种解决方法-您可以尝试像常规XML文件一样加载KML,并在本地进行解析,然后自己绘制标记,折线和多边形。 Depending on the complexity of your KML file, this could be a bit of work. 根据您KML文件的复杂程度,这可能需要一些工作。
If you can convert the data to GeoJSON (maybe using something like togeojson ) you could use google.maps.Data
to add it to your map. 如果您可以将数据转换为GeoJSON(也许使用诸如togeojson之类的东西 ),则可以使用google.maps.Data
将其添加到地图中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.