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

How do I use the LatLngBounds class in Ionic 2? #298

Closed
CardosoGit opened this issue Jul 15, 2016 · 7 comments
Closed

How do I use the LatLngBounds class in Ionic 2? #298

CardosoGit opened this issue Jul 15, 2016 · 7 comments

Comments

@CardosoGit
Copy link

CardosoGit commented Jul 15, 2016

I would like to take the center of multiple markers.

@ihadeed
Copy link
Collaborator

ihadeed commented Jul 15, 2016

import {GoogleMapsLatLngBounds, GoogleMapsLatLng} from 'ionic-native';

...


let southwest: GoogleMapsLatLng = new GoogleMapsLatLng(<lat>, <lng>);
let northeast: GoogleMapsLatLng = new GoogleMapsLatLng(<lat>, <lng>);

let bounds: LatLngBounds = new GoogleMapsLatLngBounds(southwest, northeast);
// do stuff with our bounds object now

@CardosoGit
Copy link
Author

CardosoGit commented Jul 15, 2016

I can not use this way:

var points = [
  new plugin.google.maps.LatLng(41.79883, 140.75675),
  new plugin.google.maps.LatLng(41.799240000000005, 140.75875000000002),
  new plugin.google.maps.LatLng(41.797650000000004, 140.75905),
  new plugin.google.maps.LatLng(41.79637, 140.76018000000002),
  new plugin.google.maps.LatLng(41.79567, 140.75845),
  new plugin.google.maps.LatLng(41.794470000000004, 140.75714000000002),
  new plugin.google.maps.LatLng(41.795010000000005, 140.75611),
  new plugin.google.maps.LatLng(41.79477000000001, 140.75484),
  new plugin.google.maps.LatLng(41.79576, 140.75475),
  new plugin.google.maps.LatLng(41.796150000000004, 140.75364000000002),
  new plugin.google.maps.LatLng(41.79744, 140.75454000000002),
  new plugin.google.maps.LatLng(41.79909000000001, 140.75465),
  new plugin.google.maps.LatLng(41.79883, 140.75673)
];
var latLngBounds = new plugin.google.maps.LatLngBounds(points);

map.animateCamera({
  'target' : latLngBounds
});

@CardosoGit
Copy link
Author

I changed the constructor in googlemap.js . Thus I can use as described in the above example.

function GoogleMapsLatLngBounds(arrayLatLng) {
        this._objectInstance = new plugin.google.maps.LatLngBounds(arrayLatLng);
    }

@ihadeed
Copy link
Collaborator

ihadeed commented Jul 17, 2016

thanks @CardosoGit

@CardosoGit
Copy link
Author

gratefull!

@mmazloum
Copy link

mmazloum commented Aug 5, 2016

If I may, you also have the animate camera option that should be able to take a GoogleMapsLatLngBounds as target parameter as well as GoogleMapsLatLng.

Cordova maps plugin has this feature available. Am saying this in the right place or should I create a new issue ? (sorry I'm quiet new to ionic).

@upuxaa
Copy link

upuxaa commented Sep 14, 2016

has this issue been fixed? It appears CardosoGit solution was never merged into the master...

EDIT: found the solution: #647

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants