谷歌地图kml实现 [英] google map kml implementation

查看:109
本文介绍了谷歌地图kml实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是下面的代码,用于根据kml显示地图.

This is the below code for displaying map according to kml .

var myLatLng = new google.maps.LatLng(41.875696, -87.624207);
var mapOptions = {
  zoom: 11,
  center: myLatLng,
  mapTypeId: google.maps.MapTypeId.ROADMAP
}

var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

var ctaLayer = new google.maps.KmlLayer('http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml');
ctaLayer.setMap(map);

我需要使用parse kml在地图上显示它.我将kml数据嵌入字符串中,并传递给api在地图上显示它.

What i need is using the parse kml to show it on map.I will embed the kml data in string and pass to api to show it on map.

我不希望从URL或任何文件中获取kml.我只想将kml嵌入此页面本身. 有可能这样做吗?

I dont want the kml to be fetched from url or from any file .I just want to embed kml in this page itself. Is it possible to do so ?

推荐答案

geoxml3第三方解析器具有parseKmlString方法,该方法将获取包含KML的字符串,并将其作为本机Google Maps API v3对象在Google Maps API v3地图上呈现(不是KmlLayer,因此您将失去KmlLayer为您提供的基于图块的呈现的优势).可能满足您的要求(取决于您的KML的复杂程度).

The geoxml3 third party parser has a parseKmlString method which will take a string containing KML and render it on a Google Maps API v3 map as native Google Maps API v3 objects (not a KmlLayer, so you lose the benefit of tile based rendering, that KmlLayer gives you). Might meet your requirements (will depend on how complex your KML is).

这篇关于谷歌地图kml实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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