Google Map API v3: check if geojson feature in data layer is visible

情到浓时终转凉″ 提交于 2021-02-08 08:43:38

问题


I use filters to hide or show features/markers in the Data Layer. I try to check which markers are visible after filtering, and if one property of the feature matches one property of an existing polyline (in another json file); then I decide if I show or hide the polyline also. How to know if a certain marker is visible?


回答1:


You could set a custom property on the feature and toggle it as you hide and show the feature:

feature.setProperty('visible', false);

This would have to be done in addition to the following to actually hide the feature:

map.data.overrideStyle(feature, {
  visible: false
});

Then get the property to see if it is visible:

feature.getProperty('visible');

That's what I ended up doing because I couldn't find a way to get the visible property when setting it on the feature itself with overrideStyle.



来源:https://stackoverflow.com/questions/36191132/google-map-api-v3-check-if-geojson-feature-in-data-layer-is-visible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!