-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[google_maps_flutter] Add Projection methods to google_maps #2108
Conversation
This doesn't yet expose the full projection functionality but addresses the most common usecases to translate screen coordinates to latlngs. Issue: flutter/flutter#37959
mklim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| } | ||
| case "map#getScreenCoordinate": | ||
| { | ||
| if (googleMap != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
subjective, optional: Consider using early returns/guard clauses here instead to reduce nesting.
You're doing this in multiple places, so it may even be worth extracting this out into a helper method that takes result and calls error for you and returns false if map isn't initialized. That way your checks could just be one liners guarding each method. This is just a totally optional style subjection though.
if (!assertGoogleMapInitialized(/*methodName=*/"getVisibleRegion", result)) {
return;
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting approach. I like the idea. I will revisit this in a follow-up PR.
| /// Return [ScreenCoordinate] of the [LatLng] in the current map view. | ||
| /// | ||
| /// A projection is used to translate between on screen location and geographic coordinates. | ||
| /// Screen location is in screen pixels (not display pixels) with respect to the top left corner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be useful information on ScreenInformation's DartDoc, too. I think it would be helpful to also say on the x and y members how the coordinate system works, eg is 0,0 top left or center?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this.
…2108) [google_maps_flutter] Add Projection methods to google_maps This doesn't yet expose the full projection functionality but addresses the most common use-cases to translate screen coordinates to latlngs. Issue: flutter/flutter#37959
…2108) [google_maps_flutter] Add Projection methods to google_maps This doesn't yet expose the full projection functionality but addresses the most common use-cases to translate screen coordinates to latlngs. Issue: flutter/flutter#37959
This doesn't yet expose the full projection functionality but
addresses the most common usecases to translate screen coordinates
to latlngs.
Issue: flutter/flutter#37959