API Charts for Google Maps

I have a collection of markers all showing in the correct place on my map. Then I use the following code to set the map borders so that all markers are visible.

bounds = new maps.LatLngBounds();

angular.forEach($scope.places, function(place) {
    bounds.extend(new maps.LatLng(place.getLatitude(), place.getLongitude()));
});

console.log(bounds);
map.fitBounds(bounds);
console.log(map.getBounds());

      

However, the map ends in some random place where there are no markers at all. The console.log shows that the set of bounds does not quite match the bounds returned from getBounds ().

// var bounds;
j: 40.793571
k: 40.715086

va: ih
j: -74.00108699999998
k: -73.951866

      

and

// getBounds();
j: 40.828484316202136
k: 40.68011306824231

j: -74.09878523107909
k: -73.85416776892089

      

+3
angularjs google-maps google-maps-api-3 google-maps-markers


source to share


No one has answered this question yet

See similar questions:

313
Center / Set the scale of the map to cover all visible markers?

or similar:

634
Google JS API v3 - Simple Multiple Marker Example
528
How to disable mouse wheel scaling using the Google Maps API
403
Google Maps API v3: How do I remove all markers?
269
Google Maps API v3 - Set Borders and Center
142
Google Maps API v3: Autocentre map with multiple markers
65
Using setZoom () after using fitBounds () with Google Maps API V3
2
google map map.fitBounds () and bounds.extend () are not working as expected.
0
Google Maps API redraws geocode boundaries
0
google maps get position
-1
Add markers not working on Google Maps javascript



All Articles
Loading...
X
Show
Funny
Dev
Pics