google地图如何取添加标注(取经纬度,并显示该位置显图标)?
看了一下google的API,看了半天没找到?
想请教一下做过的朋友?
google地图如何取添加标注(取经纬度,并显示该位置显图标)?
[解决办法]
可以去看我们网站,呵呵 www.niaoke.com
[解决办法]
一、google本身API就提供有(简陋)
二、向google或mapabc购买(功能全,收费)
三、自己hacker的形式(以前我实现过,不过后来据说接口改变了,所以就用不了了,要不然免费提供给你)
[解决办法]
不清楚lz具体要干什么,如果是取坐标的话,
可以参考这里的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Google Maps JavaScript API Example - simple</title> <script src="http://maps.google.com/maps?file=api&v=2&key=aaaaa" type="text/javascript" charset="utf-8"></script> </head> <body> <div id="map" style="width: 300px; height: 300px"></div> <script type="text/javascript"> //<![CDATA[ if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); map.setCenter(new GLatLng(37.441944, -122.141944), 13); } GEvent.addListener(map, 'click', function(overlay, point) { if (point) { document.getElementById("show_x").innerHTML = point.x; document.getElementById("show_y").innerHTML = point.y; } }); //]]> </script> <P id="show_x"></P> <P id="show_y"></P> </body></html>
[解决办法]
$('#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;
// }
});
myMap.addOverlay(dmarker);
document.getElementById("Label2").style.display='none';
document.getElementById("Label3").style.display='none';
//alert(x+" "+y);
GoogleMapRemoveEvent(myMap,"click");
}
});
});
参考下哈。。还可以使标注拖曳抖动。