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

Added viewBounds function to return map view bounds of all corners in Lat/Lng #81

Merged
merged 2 commits into from
Jun 16, 2021

Conversation

J-Gonzalez
Copy link

Relates to #72

Added viewBounds object. I think getBounds() or something similar would be more clear naming here, but I know nothing else has a getSomething style of naming.

Prettier went a bit wild as well 🤦 on the .ts files, changing things like the comma on the interface to semicolons (default for linting/prettier) and removing last semi on objects.

Returns data like below, where near is bottom and far is top. This is standard Google Maps naming as panning and tilting would make those areas the 'far and near' of screen.

{
    "bounds": {
        "farLeft": {
            "latitude": 32.8635086678005,
            "longitude": -117.50440925359725
        },
        "farRight": {
            "latitude": 32.8635086678005,
            "longitude": -116.81776374578475
        },
        "nearLeft": {
            "latitude": 32.567717399290665,
            "longitude": -117.50440925359725
        },
        "nearRight": {
            "latitude": 32.567717399290665,
            "longitude": -116.81776374578475
        }
    }
}

This still needs documentation on README.

@hemangsk
Copy link
Contributor

Great work! Thanks a lot :) changes LGTM

@hemangsk
Copy link
Contributor

Re prettier: Do you mind sharing the prettier config? I think its ideal to have it committed in the repo going forward

@hemangsk hemangsk merged commit 060ad59 into capacitor-community:master Jun 16, 2021
@J-Gonzalez J-Gonzalez deleted the feature/getBounds branch June 23, 2021 06:52
@stevebrowndotco
Copy link

Hello, nice update. I am using this new method straight from master in my project (as this new feature isn't available yet). The promise does not resolve. I do something like this:

        CapacitorGoogleMaps.addListener("didChange", async (resp) => {
            await CapacitorGoogleMaps.viewBounds(); // promise does not resolve
        });

jjozwiak added a commit to jjozwiak/google-maps that referenced this pull request May 7, 2022
…n Lat/Lng. Based on contribution by @J-Gonzalez PR capacitor-community#81 but updated to match project structure now being used in main branch
jjozwiak added a commit to jjozwiak/google-maps that referenced this pull request May 13, 2022
…n Lat/Lng. Based on contribution by @J-Gonzalez PR capacitor-community#81 but updated to match project structure now being used in main branch
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.

3 participants