在没有坐标的情况下绘制的折线闪烁
blinking of polyline that is drawn without co-ordinates
谁能告诉我如何使折线连续闪烁,不使用共形。我已经在没有坐标的谷歌地图中画了一条折线,但我不能像使用坐标的闪烁那样眨眼。
使用坐标闪烁折线
小提琴
没有坐标的折线(如何像上面一样闪烁这个(
小提琴
我的代码如下
$(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++;
});});
由 DirectionsRenderer 创建的折线无法通过 API 访问。
您可以做什么:切换渲染器的设置(例如 supressPolylines
( 并重绘结果:
setInterval(function () {
directionsDisplay.set('suppressPolylines',
!directionsDisplay.get('suppressPolylines'));
directionsDisplay.setDirections(result);
}, 2000);
演示:http://jsfiddle.net/doktormolle/927DS/
相关文章:
- 如何用d3.js绘制折线图
- 如何在不使用外部库的情况下使用 JavaScript 绘制折线图
- 如何在高图表中使用系列数据绘制折线图
- 当 ykey 值等于 0 且 xkey 为月时绘制折线图
- 在多个标记之间绘制折线
- 谷歌地图JavaScript绘制折线
- 在 flot.js 中绘制折线图和条形图以获取 JSON 数据
- 谷歌地图API - 在数组中使用Lat Lng坐标绘制折线飞行路径
- 使用Canvas清除并重新绘制折线图上的数据
- 谷歌地图api v3绘制折线
- 用jquery绘制折线图来表示数据库值
- 将JSON文件加载到highcharts中以绘制折线图
- 如何绘制折线,而在谷歌地图上拖动
- 不能在google maps v3上绘制折线,但可以将其点作为标记(我使用的是OpenStreetMap层)
- 在Google Maps API V3中使用LatLng坐标数组绘制折线
- 如何绘制折线在struts2使用谷歌map3
- 如何使用gMap和jQuery绘制折线
- google maps v3:绘制折线时构造函数参数0的值无效
- 绘制折线在谷歌地图街景
- 如何使用Json文件绘制折线图