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

Get LatLng bounds of mapview (NE/SE/NW/SW) #72

Open
J-Gonzalez opened this issue Jun 14, 2021 · 4 comments
Open

Get LatLng bounds of mapview (NE/SE/NW/SW) #72

J-Gonzalez opened this issue Jun 14, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@J-Gonzalez
Copy link

J-Gonzalez commented Jun 14, 2021

Is your feature request related to a problem? Please describe.
Corner bounds are extremely useful when needing to query the viewport to get points within the view.

Does this feature exist in the Google Maps SDK for android and iOS? Please link the documentation for this feature.
Yes, using "visible region"
https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/VisibleRegion?hl=en

Describe the solution you'd like
Either a getBounds function, or a way for all map events, such as on "didChange" to return bounds in addition to zoom level and center point lat/lng.

Additional context
Example swift code on didChange event that gets this data:

    public func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition) {        
        self.notifyListeners("didChange", data: ["result": [
        "position": [
            "latitude": position.target.latitude,
            "longitude": position.target.longitude
        ],
        "bounds":[
            "farLeft": [
                "latitude": mapView.projection.visibleRegion().farLeft.latitude,
                "longitude": mapView.projection.visibleRegion().farLeft.longitude,
            ],
            "farRight":[
                "latitude": mapView.projection.visibleRegion().nearRight.latitude,
                "longitude": mapView.projection.visibleRegion().nearRight.longitude,
            ]
        ],
        "zoom": position.zoom,
        ]])
    }
@J-Gonzalez J-Gonzalez added the enhancement New feature or request label Jun 14, 2021
@hemangsk hemangsk self-assigned this Jun 14, 2021
@hemangsk
Copy link
Contributor

Hey @J-Gonzalez , sounds good to me. I'm inclined towards the getBounds function approach as it seems straightforward to implement. Would you like to send a PR for this? You've the iOS parts figured out already and android seems similar.

@hemangsk hemangsk removed their assignment Jun 14, 2021
@selected-pixel-jameson
Copy link

Definitely would love to see this feature implemented as it's something we need on more then one of our projects.

@J-Gonzalez
Copy link
Author

Opened up PR #81 that creates this functionality via a viewBounds() function.

@jjozwiak
Copy link

jjozwiak commented May 6, 2022

Hello @hemangsk it looks like this enhancement exists on the v1 branch so it's not showing up when installing via npm which I imagine is pointing to the main branch.

Is this enhancement working? If so, is there a plan to merge into the main branch?

Working on a project currently that requires this capability. Thank you!

UPDATE: I just submitted a PR #171 with a modified version of @J-Gonzalez 's code so this can be merged into main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants