1

我正在使用来自这个问题的 ThinkingStiff 的代码How to move a marker in Google Maps API

如何在标记移动时添加到该代码以绘制折线?

<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){
function initialize() {

    var myLatLng = new google.maps.LatLng( 50, 50 ),
        myOptions = {
            zoom: 4,
            center: myLatLng,
            mapTypeId: google.maps.MapTypeId.ROADMAP
            },
        map = new google.maps.Map( document.getElementById( 'map-canvas' ), myOptions ),
        marker = new google.maps.Marker( {position: myLatLng, map: map} );

    marker.setMap( map );
    moveMarker( map, marker );

}

function moveMarker( map, marker ) {

    //delayed so you can see it move
    setTimeout( function(){ 

        marker.setPosition( new google.maps.LatLng( 54, 54 ) );
        map.panTo( new google.maps.LatLng( 54, 54 ) );

    }, 1500 );

};

initialize();


});//]]>  

</script>
4

0 回答 0