如何在标记移动时绘制折线

时间:2012-10-26 12:14:31

标签: google-maps

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

的ThinkingStiff的代码

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

<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>

0 个答案:

没有答案