带有方向的Google地图上的自动刷新标记 [英] auto refresh marker on google map with directions

查看:77
本文介绍了带有方向的Google地图上的自动刷新标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在地图上间隔一段时间后移动标记..
我有以下相同的代码...但是我想用某种类型的纬度和经度点数组来做到这一点,因此标记在地图上的许多点上移动了...并且还显示了这些点之间的方向...
这是我的代码...谢谢您的帮助!!!!

i want to move marker after some interval on map..
i have following code for the same...but i want to do it with some type of array of latitude and longitude points so marker is move on many points on map...and also shows the direction among that points...
here is my code...thank u for help !!!!

var locations=[
[''19.0018014'',''72.914170300''],
[''18.4915595'',''73.886065199''],
[''17.5272371'',''75.957780299''],
[''19.0787678'',''75.752507899''],
[''19.9971895'',''73.916395800''],
[''21.16536'',''72.79387'']
];
 
var map;
var NewLatLng=[];
var markers=[];
var marker ;
   function initialize()
  {
        var latlng = new google.maps.LatLng(21.16536,72.79387);
        var myOptions = {
        zoom: 5,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById("map"), myOptions);
        map = new google.maps.Map(document.getElementById("map"), myOptions);
        marker = new google.maps.Marker(
        {
            position: new google.maps.LatLng(21.1673643, 72.7851802),
            map: map,
            title: ''Click me''
        });
        markers.push(marker);
        $.each(locations, function (i, item) {
            NewLatLng.push(new google.maps.LatLng(item[0], item[1]));
        });
        var infowindow = new google.maps.InfoWindow({
            content: ''Location info:<br/>Movable Marker !!''

        });
        google.maps.event.addListener(marker, ''click'', function ()
        {
            infowindow.open(map, marker);
            setTimeout(function(){infowindow.close();}, ''5000'');
        });
        $.each(NewLatLng, function (i, item) {
            setTimeout(function(){
            marker.setPosition(item);

            markers.push(marker);

            }, i*3000);

        });
    
    }
    window.onload =initialize;

推荐答案

.each(locations,location(function(i,item)){ NewLatLng.push(new google.maps.LatLng(item [0],item [1])); }); var infowindow = new google.maps.InfoWindow({ 内容:位置信息:< br/>可移动标记!!" }); google.maps.event.addListener(marker,``click'',function() { infowindow.open(地图,标记); setTimeout(function(){infowindow.close();},``5000''); });
.each(locations, function (i, item) { NewLatLng.push(new google.maps.LatLng(item[0], item[1])); }); var infowindow = new google.maps.InfoWindow({ content: ''Location info:<br/>Movable Marker !!'' }); google.maps.event.addListener(marker, ''click'', function () { infowindow.open(map, marker); setTimeout(function(){infowindow.close();}, ''5000''); });


.each(NewLatLng,function(i,item){ setTimeout(function(){ marker.setPosition(item); markers.push(marker); },i * 3000); }); } window.onload = initialize;
.each(NewLatLng, function (i, item) { setTimeout(function(){ marker.setPosition(item); markers.push(marker); }, i*3000); }); } window.onload =initialize;


如果您需要显示这些标记点之间的路径,请尝试...

If you need to display the path between those marker points try this...

var locations=[
['19.0018014','72.914170300'],
['18.4915595','73.886065199'],
['17.5272371','75.957780299'],
['19.0787678','75.752507899'],
['19.9971895','73.916395800'],
['21.16536','72.79387']
];

var map;
var NewLatLng=[];
var NewLatLng1=[]
var markers=[];
var marker ;
   function initialize()
  {
        var latlng = new google.maps.LatLng(21.16536,72.79387);
        var myOptions = {
        zoom: 5,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById("map"), myOptions);
        map = new google.maps.Map(document.getElementById("map"), myOptions);
        marker = new google.maps.Marker(
        {
            position: new google.maps.LatLng(21.1673643, 72.7851802),
            map: map,
            title: 'Click me'
        });
        markers.push(marker);


这篇关于带有方向的Google地图上的自动刷新标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆