问题
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.
Here is the script tag:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"> </script>
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);
});
And here is the KML file:
<?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>
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.
回答1:
KML coordinates are longitude,latitude; no spaces allowed.
来源:https://stackoverflow.com/questions/21815852/basic-kml-with-google-map-api-not-working