0

我正在使用简单的代码在我的网站上创建地图:

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
var map;
function initialize() {
    var mapOptions = {
    zoom: 12,
    scrollwheel: false,
        center: new google.maps.LatLng(38.80962, -77.13143),
        mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),
    mapOptions);
    var customMarker = new google.maps.Marker({
        position: latlng,
        map: map,
        shadow: shadow,
        title:"Carlos Gallupa HQ",
        icon: image
    });
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>

现在我在使用标记精确定位我的位置时遇到问题。知道如何简单而正确地做到这一点吗?谢谢。

4

1 回答 1

0

It looks as if your marker position is not defined anywhere. Try this:

var customMarker = new google.maps.Marker({
    // Here is the change:
    position: map.getCenter(),
    map: map,
    shadow: shadow,
    title:"Carlos Gallupa HQ",
    icon: image
});
于 2013-03-01T17:36:24.990 回答