具有方向的地图上的自动刷新标记 [英] auto refresh marker on map with direction
本文介绍了具有方向的地图上的自动刷新标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在地图上间隔一段时间后移动标记..
我有以下标记代码,它们之间的间隔设置为3秒,并且在这些标记之间也设置了折线.
但是我想在这些标记之间以及在infoWindow中显示方向,该标记的纬度和经度会显示出来...
意味着在信息窗口中将显示a的纬度日志..
这是我的代码...谢谢您的帮助!!!!
i want to move marker after some interval on map..
i have following code for markers that set with interval of 3 second and also set polyline between those markers..
but i want to show direction between those marker and also in infoWindow ,latitude and longitude of that marker is display...
means at place A lat-log of a will be shown in infoWindow..
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 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);
$.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);
NewLatLng1.push(item);
var flightPath = new google.maps.Polyline({
path: NewLatLng1,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
}, i*3000);
});
}
window.onload =initialize;
推荐答案
.each(locations,location(function(i,item){ NewLatLng.push(新 google.maps.LatLng(item [ 0 ],项目[ 1 ]))); }); var infowindow = 新 google.maps.InfoWindow({ 内容:' 位置信息:< br/>可移动标记!!' }); google.maps.事件 .addListener(标记,' 点击',函数() { 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); NewLatLng1.push(item); var flightPath = 新 google.maps.Polyline({ 路径:NewLatLng1, strokeColor:' #FF0000', strokeOpacity: 1 . 0 , strokeWeight: 2 }); flightPath.setMap(map); },i * 3000); }); } window.onload = initialize;
.each(NewLatLng, function (i, item) { setTimeout(function(){ marker.setPosition(item); markers.push(marker); NewLatLng1.push(item); var flightPath = new google.maps.Polyline({ path: NewLatLng1, strokeColor: '#FF0000', strokeOpacity: 1.0, strokeWeight: 2 }); flightPath.setMap(map); }, i*3000); }); } window.onload =initialize;
这篇关于具有方向的地图上的自动刷新标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文