Google地图数据图层,点击多边形并更改不透明度(Chrome Bug) [英] Google Map Data Layer, click on polygon and change opacity (Chrome Bug)

查看:156
本文介绍了Google地图数据图层,点击多边形并更改不透明度(Chrome Bug)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个谷歌地图,我使用addGeoJson将几何数据*加载到数据图层。一切工作正常,直到我试图绑定事件的多边形,以改变opactiy设置。

*我从OSM retreive城市边界绘制多边形,我认为我的json对象格式良好,我以Google为参考: https://storage.googleapis.com/ mapsdevsite / json / google.json



只要我点击一个多边形(它们中的任何一个),它似乎就会复制我的多边形,不透明度的变化正确。



我用这个例子作为我的代码: https://developers.google.com/maps/documentation/javascript/examples/layer-data-dynamic



这是我的JSFiddle: https://jsfiddle.net/fmarrot/k7b57egw/(数据可以在console.log(Config.polygon)(第10行)中可以看到。

事实上,如果我将第29行注释到31,完全没有问题,但我无法更改

  map.data.addListener('click',function(event){
event.feature .setProperty('opacity',(event.feature.getProperty('opacity')=== 0.5?0.9:0.5));
});

任何想法我做错了什么?



感谢您的帮助!

解决方案

好的我想我明白了,它似乎是一个Chrome bug(我的版本58.0.3029.110(64位)),我刚刚用Firefox,Edge和IE进行了测试,没有任何问题>多边形点击没有多边形重复,并且像一个魅力一样!



我会等待Chrome修复程序,或者如果有人有解决方案,我将不胜感激任何建议!
$ b 更新



正如Google问题跟踪器所述,问题已在Chrome 60中修复。相应的错误在2017年8月9日标记为已修复。



https://buganizer.corp.google.com/issues/38211242


I have a google map where I load geometry data* to the data layer using addGeoJson. Everything works fine until i tried to bind an event on polygons in order to change opactiy settings.

*I retreive city borders from OSM to draw polygons, I think my json object is well formatted, I took Google as reference : https://storage.googleapis.com/mapsdevsite/json/google.json

As soon as I click on a polygon (any of them), it seems to duplicates my polygons anywhere around however the opacity change correctly.

I used this as exemple for my code : https://developers.google.com/maps/documentation/javascript/examples/layer-data-dynamic

Here is my JSFiddle : https://jsfiddle.net/fmarrot/k7b57egw/ (the data can be seen in console.log(Config.polygon) (line 10)

Indeed if i comment line 29 to 31, no problem at all, but I can't change polygon opacity anymore.

map.data.addListener('click', function(event) {
  event.feature.setProperty('opacity', (event.feature.getProperty('opacity')===0.5?0.9:0.5));
});

Any idea of what I am doing wrong ?

Thanks for your help !

解决方案

Ok I think I figured out, it seems to be a Chrome bug (my version 58.0.3029.110 (64-bit)), I've just tested it with Firefox, Edge and IE with no problems > no polygons duplications on polygon click and works like a charm !

I am gonna wait for a chrome fix or if someone have a solution I would appreciate any suggestions !

UPDATE

As stated in Google issue tracker, the issue was fixed in Chrome 60. The corresponding bug was marked as Fixed on August 9, 2017.

https://buganizer.corp.google.com/issues/38211242

这篇关于Google地图数据图层,点击多边形并更改不透明度(Chrome Bug)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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