【发布时间】:2015-04-08 09:43:41
【问题描述】:
我有一个网站,我可以在该网站上加载和使用 kmz 文件。我的问题是 GEO 位置不工作,我的意思是它工作但它没有显示街道,因为 Javascript 加载 kmz 文件并将焦点集中在 KMZ 地图而不是您的 GEOlocation。
不管怎样,这里是代码,所以你可以看看有什么问题:
<script type="text/javascript">
var map, infoWindow;
$(document).ready(function(){
infoWindow = new google.maps.InfoWindow({});
map = new GMaps({
el: '#map',
zoom: 20,
lat: 46.044414,
lng: 14.508105,
});
map.loadFromKML({
url: 'http://blabla.com/blabla.kmz',
url: 'http://blabla.com/blabla2.kmz',
suppressInfoWindows: true,
events: {
click: function(point){
infoWindow.setContent(point.featureData.infoWindowHtml);
infoWindow.setPosition(point.latLng);
infoWindow.open(map.map);
}
}
});
});
</script>
<script type="text/javascript">
GMaps.geolocate({
success: function(position) {
map.setCenter(position.coords.latitude, position.coords.longitude);
},
error: function(error) {
alert('Geolocation failed: '+error.message);
},
not_supported: function() {
alert("Your browser does not support geolocation");
},
always: function() {
alert("Success!");
}
});
</script>
哦,我差点忘了,我正在使用 Gmaps.js
【问题讨论】:
标签: javascript google-maps geolocation kmz