我正在创建一个带有可拖动标记的谷歌地图。创建标记后,以后如何更改其位置?我可以用setposition(latlng)
这个吗?如果是,如何?这是我创建 Google Map 3 实例的代码:
function showm(la,lo) {
$('#gmap').hide();
alert(lo);
$('#gmap').gmap3({
marker:{
latLng: [la,lo],
options:{
draggable:true
},
events:{
dragend: function(marker){
$(this).gmap3({
getaddress:{
latLng:marker.getPosition(),
callback:function(results){
alert(marker.getPosition().lat());
var map = $(this).gmap3("get"),
infowindow = $(this).gmap3({get:"infowindow"}),
content = results && results[1] ? results[0].formatted_address : "no address";
if (infowindow){
infowindow.open(map, marker);
infowindow.setContent(content);
} else {
$(this).gmap3({
infowindow:{
anchor:marker,
options:{content: content}
}
});
}
}
}
});
}
}
},
map:{
options:{
zoom: 12
}
}
});
$('#gmap').show();
}