我想在此代码中添加“简单标记”..但我对javascript非常困惑
这是代码:
<script type="text/javascript">
map = new GMap2(document.getElementById("mapa"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl(3));
map.setCenter( new GLatLng(-7.263372623252126, 112.75139808654785), 14,0);
GEvent.addListener(map,'mousemove',function(point)
{
document.getElementById('latspan').innerHTML = point.lat()
document.getElementById('lngspan').innerHTML = point.lng()
document.getElementById('latlong').innerHTML = point.lat() + ', ' + point.lng()
});
GEvent.addListener(map,'click',function(overlay,point)
{
document.getElementById('latlongclicked').value = point.lat() + ', ' + point.lng()
});
</script>
答案 0 :(得分:1)
请参阅:Adding a marker to GMaps (google maps)
顺便说一下,你可以试试这个
map.addMarker({
lat: -12.043333,
lng: -77.028333,
title: 'Lima',
click: function(e) {
alert('You clicked in this marker');
}
});
或阅读官方文档:https://developers.google.com/maps/documentation/javascript/examples/marker-simple?hl=es-419