Closed alejandrovgonzalez closed 3 years ago
(A) You can specify array of ILatLng to the target property of the map.animateCamera(), or
(B) you can zoom out with map.animateZoomOutCamera() and get the visible region through map.getVisibleRegion()
title
and snippet
, marker does not show infowinfow.Regarding your idea A: The problem is that when giving an array of ILatLng the current camera center is lost. Regarding your idea B: It actually works, though it looks weird since if you need to zoom out more than 1 time it stops to zoom out again.
I would guess the functionality would be something like Google Maps API fitBounds()
method https://developers.google.com/maps/documentation/javascript/reference/map#Map.fitBounds.
If I manage to find a way to do it I will share it here.
This plugin provides fitBounds
as Array of ILatLng
.
In side the plugin, calculates the bounds, then fit the camera to the bounds.
You need to include proper points.
Or you can also pass northWest/southEast pairs based on your pre calculated bounds.
Just zooming out keeping map.animateZoomOutCamera()
Inside the plugin, map.animateZoomOutCamera()
is map.animateCamera()
Originally this plugin provides only two methods map.animateCamera()
and map.moveCamera()
.
You can specify more exact parameters using map.animateCamera()
method.
All source code is open :)
After researching a bit and trying what you suggested (which didn't work for me) I ended up looking at some algorithm that would do the job. I increase the area usign this:
extendArea(
northEast: LatLng,
southWest: LatLng,
increasePercentage: number
): { northEast: LatLng; southWest: LatLng } {
let latAdjustment =
(northEast.lat - southWest.lat) * (increasePercentage - 1);
let lngAdjustment =
(northEast.lng - southWest.lng) * (increasePercentage - 1);
return {
northEast: new LatLng(
northEast.lat + latAdjustment,
northEast.lng + lngAdjustment
),
southWest: new LatLng(
southWest.lat - latAdjustment,
southWest.lng - lngAdjustment
),
};
}
and every time is increased I check if the coordinates of the POI I search for is inside the northEast/southWest area. The increasePercentage
value can be for example 1.1
for a 10% area increase. When the POI fits the area, I just animate the camera to fit the northEast/southWest coordinates. The good thing about this method is that if the map is centered in the user and you use map.getVisibleRegion()
to get the initial's area northEast/southWest, when you move the map to the newly found area the user will still be in the center.
I'm submitting a ... (check one with "x")
cordova information: (run
$> cordova plugin list
)If you use
@ionic-native/google-maps
, please tell the package.json (only@ionic-native/core
and@ionic-native/google-maps
are fine mostly)Questions Hello, first of all, thanks for this amazing plugin. I have a couple of questions that couldn't find or missed in the docs.
Thank you in advance for the help.