小编Nic*_*mon的帖子

数据层:动态样式

我正在使用以下函数在地图上设置折线样式:

countyLayer.addListener('click', function(event) {

  countyLayer.overrideStyle(event.feature, {strokeWeight: 8});

});
Run Code Online (Sandbox Code Playgroud)

现在我想在点击折线时删除样式,如果之前已设置样式.

我试过这个:

countyLayer.addListener('click', function(event) {

  if (feature.strokeWeight == 8){  //problem is here I think ?

     countyLayer.overrideStyle(event.feature, {strokeWeight: 2});
  }
   else {
     countyLayer.overrideStyle(event.feature, {strokeWeight: 8});
   }
 });
Run Code Online (Sandbox Code Playgroud)

我试着在这里获得一些帮助:https://developers.google.com/maps/documentation/javascript/examples/layer-data-dynamic 但他没有解释如何删除点击样式

谢谢你的帮助

styling google-maps-api-3

0
推荐指数
1
解决办法
1877
查看次数

标签 统计

google-maps-api-3 ×1

styling ×1