问题
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