本文介绍了带有Google Map API的基本KML无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用KML尝试了我的第一个Google Map API,但它对我炸毁了.似乎只是一个非常基本的问题,但却无法使其正常工作.
I tried my first Google Map API with KML and it bombed on me. Just seem to be a very basic problem but just can't get it to work.
这是脚本标签:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"> </script>
这是Javascript:
Here is the Javascript:
$(document).ready(function () {
map_center = new google.maps.LatLng(-34.397, 150.644);
var mapOptions = {
zoom: 8,
center: map_center
};
var kml_map = new google.maps.Map(document.getElementById('map_div'), mapOptions);
var kml_layer = new google.maps.KmlLayer({
preserveViewport: true,
url: 'http://someurl/mykml.kml' //Of course, I am using a valid URL here for "someurl"
});
kml_layer.setMap(kml_map);
});
这是KML文件:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Placemark>
<name>My placemark!</name>
<description>Some description of my placemark.</description>
<Point>
<coordinates>-34.397, 150.644</coordinates>
</Point>
</Placemark>
</kml>
我看不到地标.我看到整个星球的GoogleMap都没有缩放...没别的.我要去哪里错了?控制台中也没有错误.
I do not see the placemark. I see the GoogleMap of the whole planet with no zoom... nothing else. Where am I going wrong? No errors in the console either.
推荐答案
KML坐标是经度,纬度;不允许有空格.
这篇关于带有Google Map API的基本KML无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!