时间:2021-07-01 10:21:17 帮助过:18人阅读
Google Maps JavaScript API Example - simple
------解决方案--------------------
$('#Label2').click(function() {
GoogleMapAddEvent(myMap, "click", function(marker, point) {
if(marker)
{
myMap.removeOverlay(marker);
}
else
{
// myMap.clearOverlays();
var dmarker = new GMarker(point, {draggable: true});
var dpoint;
var x;
var y;
x = GoogleMapPointX(point);
y = GoogleMapPointY(point);
document.getElementById("TextBox2").value = x;
document.getElementById("TextBox1").value = y;
// if(document.getElementById("hidsyid").value=='')//为空表示初始传进来的监测点编码
// {
document.getElementById("hidw").value=x;
document.getElementById("hidj").value=y;
// }
GEvent.addListener(dmarker, "dragstart", function(){
});
GEvent.addListener(dmarker, "dragend", function(){
dpoint=dmarker.getPoint();
myMap.panTo(dpoint);
x = dpoint.lat();
y = dpoint.lng();
document.getElementById("TextBox2").value = x;
document.getElementById("TextBox1").value = y;
// if(document.getElementById("hidsyid").value=='')
// {
document.getElementById("hidw").value=x;
document.getElementById("hidj").value=y;