Javascript 不带坐标绘制的多段线闪烁
谁能告诉我如何使多段线连续闪烁,不使用坐标系。我在谷歌地图上画了一条没有坐标的多段线,但我不能让它像使用坐标的闪烁一样闪烁 带坐标的闪烁多段线 没有坐标的多段线(如何像上面一样闪烁此多段线) 我的代码如下所示Javascript 不带坐标绘制的多段线闪烁,javascript,google-maps,google-maps-api-3,polyline,blink,Javascript,Google Maps,Google Maps Api 3,Polyline,Blink,谁能告诉我如何使多段线连续闪烁,不使用坐标系。我在谷歌地图上画了一条没有坐标的多段线,但我不能让它像使用坐标的闪烁一样闪烁 带坐标的闪烁多段线 没有坐标的多段线(如何像上面一样闪烁此多段线) 我的代码如下所示 $(function(){ var map = new google.maps.Map(document.getElementById("map"), { center: new google.maps.LatLng(11.275387916
$(function(){
var map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng(11.275387916698238, 75.8015380957031),
zoom: 12
}),
routes = [{origin:'p t usha road, kozhikode',
destination:'cooperative hospital, eranjipalam, kozhikode'
},
{origin:'IIM, Kozhikode',
destination:'VELLIMADUKUNNU, KOZHIKODE'
}
],
rendererOptions = {
preserveViewport: true,
map:map,
polylineOptions:{strokeColor:'#FF3300',
strokeWeight: 10},
suppressMarkers:true,
routeIndex:0
},
directionsService = new google.maps.DirectionsService();
var i=0;
var infowindow = new google.maps.InfoWindow();
$.each(routes,
function(i,obj){//<--anonymous function
var request = {
origin: obj.origin,
destination: obj.destination,
travelMode: google.maps.TravelMode.DRIVING
},
directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);
directionsService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
var lat = result.routes[0].legs[0].start_location.lat();
var lon = result.routes[0].legs[0].start_location.lng();
var lat1 = result.routes[0].legs[0].end_location.lat();
var lon1 = result.routes[0].legs[0].end_location.lng();
try{
var marker1 = new google.maps.Marker({
position: new google.maps.LatLng(lat, lon),
icon:'https://mts.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-b.png&text=B&psize=16&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48&scale=1',
map: map
});
google.maps.event.addListener(marker1, 'click', (function(marker1, i) {
return function() {
infowindow.setContent('hh');
infowindow.open(map, marker1);
}
})(marker1, i));
}catch(e){alert(e)}
try{
var marker2 = new google.maps.Marker({
position: new google.maps.LatLng(lat1, lon1),
icon:'https://mts.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png&text=A&psize=16&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48&scale=1',
map: map
});
google.maps.event.addListener(marker2, 'click', (function(marker2, i) {
return function() {
infowindow.setContent('hdddh');
infowindow.open(map, marker2);
}
})(marker2, i));
}catch(e){alert(e)}
directionsDisplay.setDirections(result);
}
});
i++;
});});
$(函数(){
var map=new google.maps.map(document.getElementById(“map”){
中心:新google.maps.LatLng(11.27538791669823875.8015380957031),
缩放:12
}),
路线=[{产地:'p t usha路,kozhikode',
目的地:科日科德埃兰吉帕兰合作医院
},
{来源:'IIM,Kozhikode',
目的地:'VELLIMADUKUNNU,KOZHIKODE'
}
],
渲染器选项={
对,,
地图:地图,
多段线选项:{strokeColor:'#FF3300',
冲程重量:10},
对,,
路由索引:0
},
directionsService=new google.maps.directionsService();
var i=0;
var infowindow=new google.maps.infowindow();
$。每条(路线,
函数(i,obj){/DirectionsRenderer创建的多段线不能通过API访问
您可以执行的操作:切换渲染器的设置(例如,superspolylines
)并重新绘制结果:
setInterval(function () {
directionsDisplay.set('suppressPolylines',
!directionsDisplay.get('suppressPolylines'));
directionsDisplay.setDirections(result);
}, 2000);
演示:当您说“无坐标”时,您询问的是由渲染的多段线。您的小提琴上显示了两个方向的结果。您想做什么?使它们都闪烁?一个而不是另一个?