fitbounds

fitBounds() shows whole earth (if map is first hidden and then shown)

跟風遠走 提交于 2019-12-04 18:54:25
问题 I have a bunch or markers, and I want to show only the area containing them. I found a long list of similar questions (see at the bottom of the post for some), but none of the solutions works for me. The LatLngBounds is built correctly, but when I call fitBounds the result will be the following: Instead of: Can anybody spot an evident error in my code? var opt = { zoom: 8, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("map"),opt); var box = new

google maps API 3 zooms out on fitBounds

假如想象 提交于 2019-12-04 01:01:21
问题 I've run into a problem where calling map.fitBounds seems to zoom out. I'm trying to use the backbone.js router to save the map bounds in the url. I want to be able to bookmark the url and later have the map look exactly the same. I noticed calling map.fitBounds(map.getBounds()) in the console will always zoom out. Where as I would like it to not change the map. Is this normal behaviour? How can I enforce this so the map will look the same from one step to the next? Thanks 回答1: This problem

Google Maps API V3 fitbounds() zooms out but never in

£可爱£侵袭症+ 提交于 2019-12-04 00:38:10
问题 I've created a quite complex store locator of sorts. The user enters their zip and a table returns results with corresponding markers on a map. They can page through results and the markers move further and further out and the fitbounds() function works great for zoom out to the appropriate zoom level to fit the markers. The problem is that if you page back to closer locations the fitbounds() doesn't zoom in. Even if you enter a new search it doesn't zoom in around those new markers -- it

Google maps fitBounds with padding? [duplicate]

和自甴很熟 提交于 2019-12-01 14:53:35
This question already has an answer here: Google Maps API 3 fitBounds padding - ensure markers are not obscured by overlaid controls 7 answers We want something like this leaflet fitBounds in our google maps application. We saw a few examples but it doesn't worked as expected. We tried to make the div as a google maps controller, extend the bounds manually but nothing from that worked... function zoomToBounds(polygon){ bounds = new google.maps.LatLngBounds(); $.each(polygon, function( key, latLng ) { bounds.extend(new google.maps.LatLng(latLng.lat, latLng.lng)); }); ///////////////////////////

Google maps fitBounds with padding? [duplicate]

吃可爱长大的小学妹 提交于 2019-12-01 14:26:27
问题 This question already has answers here : Google Maps API 3 fitBounds padding - ensure markers are not obscured by overlaid controls (7 answers) Closed 3 years ago . We want something like this leaflet fitBounds in our google maps application. We saw a few examples but it doesn't worked as expected. We tried to make the div as a google maps controller, extend the bounds manually but nothing from that worked... function zoomToBounds(polygon){ bounds = new google.maps.LatLngBounds(); $.each

Google Maps JavaScript API - fitbounds together with setCenter

亡梦爱人 提交于 2019-12-01 09:10:48
I've been looking around for a solution to this problem, but i can't seem to find somthing that solves this. The closest i get is this thread . But this doesn't work. What i'm trying to do is to run fitbounds based on a set of markers which works fine. But i would also like to center the map based on the users location (the bouncing marker in the plunk) and still keep all markers within the map view. If i try to setCenter after fitBounds, some markers are outside of the map view. Is there some nifty way of combining these two functions? Here's the plunk illustrating the issue . function

Google Maps JavaScript API - fitbounds together with setCenter

偶尔善良 提交于 2019-12-01 06:04:57
问题 I've been looking around for a solution to this problem, but i can't seem to find somthing that solves this. The closest i get is this thread. But this doesn't work. What i'm trying to do is to run fitbounds based on a set of markers which works fine. But i would also like to center the map based on the users location (the bouncing marker in the plunk) and still keep all markers within the map view. If i try to setCenter after fitBounds, some markers are outside of the map view. Is there some

google maps API 3 zooms out on fitBounds

浪尽此生 提交于 2019-12-01 03:55:48
I've run into a problem where calling map.fitBounds seems to zoom out. I'm trying to use the backbone.js router to save the map bounds in the url. I want to be able to bookmark the url and later have the map look exactly the same. I noticed calling map.fitBounds(map.getBounds()) in the console will always zoom out. Where as I would like it to not change the map. Is this normal behaviour? How can I enforce this so the map will look the same from one step to the next? Thanks This problem of Google Map API was discussed few times. See: gmaps-api-issues google-maps-js-api-v3 group Function map

Google Maps v3: Enforcing min. zoom level when using fitBounds

自古美人都是妖i 提交于 2019-11-30 06:14:34
问题 I'm drawing a series of markers on a map (using v3 of the maps api). In v2, I had the following code: bounds = new GLatLngBounds(); ... loop thru and put markers on map ... bounds.extend(point); ... end looping map.setCenter(bounds.getCenter()); var level = map.getBoundsZoomLevel(bounds); if ( level == 1 ) level = 5; map.setZoom(level > 6 ? 6 : level); And that work fine to ensure that there was always an appropriate level of detail displayed on the map. I'm trying to duplicate this

Google Maps v3: Enforcing min. zoom level when using fitBounds

青春壹個敷衍的年華 提交于 2019-11-29 19:35:06
I'm drawing a series of markers on a map (using v3 of the maps api). In v2, I had the following code: bounds = new GLatLngBounds(); ... loop thru and put markers on map ... bounds.extend(point); ... end looping map.setCenter(bounds.getCenter()); var level = map.getBoundsZoomLevel(bounds); if ( level == 1 ) level = 5; map.setZoom(level > 6 ? 6 : level); And that work fine to ensure that there was always an appropriate level of detail displayed on the map. I'm trying to duplicate this functionality in v3, but the setZoom and fitBounds don't seem to be cooperating: ... loop thru and put markers