Javascript 如何在gmap3中按经纬度设置位置
我是javascript新手,正在尝试使用gmap3脚本。在为lat和lng创建了两个变量后,我想通过尝试使用的纬度和经度在地图中显示一个特定的位置Javascript 如何在gmap3中按经纬度设置位置,javascript,Javascript,我是javascript新手,正在尝试使用gmap3脚本。在为lat和lng创建了两个变量后,我想通过尝试使用的纬度和经度在地图中显示一个特定的位置 var lat = $("#localizacao_lat").text(); var lng = $("#localizacao_lng").text(); $(function() { $("#map").gmap3({ marker:{ latLng: [lat, lng], 但我的地图上什么也看不出
var lat = $("#localizacao_lat").text();
var lng = $("#localizacao_lng").text();
$(function() {
$("#map").gmap3({
marker:{
latLng: [lat, lng],
但我的地图上什么也看不出来。如果有人能帮我解决这个问题,我会非常高兴的。请在完整的源代码下面找到代码
谢谢。
吉米
$(函数(){
$(“#地图”).gmap3({
地图:{
选项:{
缩放:14,
}
},
getlatlng:{
/*地址:“,*///键入地址
回调:函数(结果){
如果(!results)返回;
$(this.gmap3('get').setCenter(新的google.maps.LatLng(结果[0].geometry.location.lat(),结果[0].geometry.location.lng());
$(本文件)。gmap3({
标记:{
latLng:结果[0]。几何体。位置,
选项:{
图标:“images/map pin.png”
}
}
});
}
}
});
});
我想通过lng和lat而不是通过地址来展示
<script type="text/javascript">
$(function() {
$("#map").gmap3({
map:{
options:{
zoom: 14,
}
},
getlatlng:{
/* address: " ,*/ //Type the address
callback: function(results) {
if ( !results ) return;
$(this).gmap3('get').setCenter(new google.maps.LatLng(results[0].geometry.location.lat(), results[0].geometry.location.lng()));
$(this).gmap3({
marker:{
latLng:results[0].geometry.location,
options:{
icon: 'images/map-pin.png'
}
}
});
}
}
});
});
</script>