改变DirectionsRenderer中折线的颜色 [英] change the color of the polyline in DirectionsRenderer

查看:168
本文介绍了改变DirectionsRenderer中折线的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我整合了一张地图,我想要显示两个地点之间的路线方向。
一切工作正常,方向显示完美,
但我想改变 Polyline 方向的颜色,我试过这段代码就像文档中所说的:

pre $ $ $ $ $ $ $ $ $ $ $ $ $变量$选项= {
map:map,
strokeColor:#2249a3,
strokeOpacity:0.9,
strokeWeight:12,
z-index:99
};
logJava(polylineOptions);

// directionsRenderer选项
var mDirectionsRendererOptions = {
map:map,
suppressMarkers:true,
suppressInfoWindows:true,
polylineOptions: pOptions
};

logJava(mDirectionsRendererOptions);

directionsDisplay = new google.maps.DirectionsRenderer(mDirectionsRendererOptions);

但是当我添加这段代码时,它停止了地图,当我评论它时什么都不显示,一切工作正常。



这段代码有什么问题,以及如何使用 google maps javascript api v3 更改多段线的颜色?



在此先感谢,

解决方案

在全局声明中

  var polylineOptionsActual = new google.maps.Polyline({
strokeColor:'#FF0000',
strokeOpacity:1.0,
strokeWeight:10
});

初始化

  function initialize(){
directionsDisplay = new google.maps.DirectionsRenderer({polylineOptions:polylineOptionsActual});


i've integrated a map and i want to display the route directions between two locations. everything is working fine and the directions is displayed perfectly , but i want to change the color of the Polyline direction ,i've tried this code like the documentation says :

//polyline options
    var pOptions = {
            map: map,
            strokeColor: "#2249a3",
            strokeOpacity: 0.9 ,
            strokeWeight: 12,
            z-index: 99
    };
    logJava(polylineOptions);

    //directionsRenderer options
    var mDirectionsRendererOptions = {
            map: map,
            suppressMarkers: true,
            suppressInfoWindows: true,
            polylineOptions: pOptions
    };

    logJava(mDirectionsRendererOptions);

    directionsDisplay = new google.maps.DirectionsRenderer(mDirectionsRendererOptions);

but when i add this code , it stops the map , and it displays nothing, when i comment it , everything is working fine .

what is wrong with this code, and how to change the color of the polyline with google maps javascript api v3 ?

Thanks in advance,

解决方案

At global declarations

var polylineOptionsActual = new google.maps.Polyline({
    strokeColor: '#FF0000',
    strokeOpacity: 1.0,
    strokeWeight: 10
    });

At initialise

function initialize() {
   directionsDisplay = new google.maps.DirectionsRenderer({polylineOptions: polylineOptionsActual});    

这篇关于改变DirectionsRenderer中折线的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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