Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set polygon clickable option with style instead of forced true. #454

Merged
merged 1 commit into from May 1, 2018

Conversation

Qwatcha
Copy link
Contributor

@Qwatcha Qwatcha commented Apr 26, 2018

setOnMapClickListener not called when clicking on map area with GeoJson polygon added. Polygon clickable option was set to true. Allow the user to set the clickable option.

Patch file with modified GeoJsonDemoActivity.java to test setting clickable style
Demo_of_clickable_polygon_or_clicking_through.zip

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@googlebot
Copy link

CLAs look good, thanks!

@stephenmcd
Copy link
Contributor

Thanks

@stephenmcd stephenmcd merged commit 0005ae7 into googlemaps:master May 1, 2018
@Qwatcha Qwatcha deleted the geojson_polygon_clickable branch May 1, 2018 10:46
barbeau added a commit that referenced this pull request Jan 31, 2020
As discussed in #558, the original intent when combining the KML and GeoJSON renderers was to have GeoJSON and KML lines and polygons clickable by default.

However, there was a regression in #454 that unintentionally disabled clicks for KML and GeoJSON polygons when attempting to allow developers to use GeoJSON custom styles to set clickable.

I investigated both KML and GeoJSON lines and polygons, and here is the current state of the library:

* For KML/GeoJSON polygons - we're currently supporting developer-defined clickable styles for GeoJSON (the change in #454), but that results in a default of not clickable for GeoJSON and KML. And there isn't a way to override the default in KmlLayer.
* For KML/GeoJSON lines - we're currently ignoring developer-defined clickable styles and hard-coding the default clickable style to true.

This PR solves both problems (default of "not clickable" and supporting developer-defined styles) as follows:

* Makes all styles for GeoJSON and KML lines and polygons clickable by default by setting clickable=true in style constructors rather than the renderer. This also allows the developer to set a custom style with clickable=false on GeoJSON lines and polygons (custom programmatic KML styles currently aren't supported by the library).
* Make clickable default to true in the Style superclass - this should hopefully avoid a similar issue in any new implementations that extend Style
* Normalize the GeoJsonLineStringStyle and GeoJsonPolygonStyle clickable implementations - GeoJsonPolygonStyle was missing code related to the clickable attribute
* Add missing <name> attribute to the KML polygon demo file used in the MultiLayerDemoActivity
* Add unit tests:
    * For GeoJSON - test both default and programmatic custom clickable styles for both the style and renderer classes
    * For KML - test the default style for both the style and renderer classes
    * Refactor KML and GeoJSON test utility methods used in more than one test class to new Kml/GeoJsonTestUtil classes
    * Fix GeoJSON polygonStyle.toPolygonOptions().isVisible() test (this previously didn't check PolygonOptions)

I've also added TODO statements in the unit tests where we could expand coverage further (i.e., after adding the layers to the map), but that requires additional test instrumentation to have a live GoogleMap object.

Fixes #558

Refs: 558
@barbeau barbeau mentioned this pull request Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants