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 to set map bounds #138

Open
Pugglewuggle opened this issue Mar 3, 2017 · 7 comments
Open

How to set map bounds #138

Pugglewuggle opened this issue Mar 3, 2017 · 7 comments

Comments

@Pugglewuggle
Copy link

Is there a way to set the map bounds like you can in the Gmaps JS API? I have a set of bounds... can I set the map to use those instead of setting a static zoom level and center?

@jmelosegui
Copy link
Owner

jmelosegui commented Mar 3, 2017

does this sample help?

http://www.jmelosegui.com/map/marker/FitToMarkersBounds

@jmelosegui jmelosegui reopened this Mar 3, 2017
@Pugglewuggle
Copy link
Author

Hi, Isn't that only for markers? I actually need to set the bounds to set of coordinates - though there will be no markers on the map for the coordinates.

@Pugglewuggle
Copy link
Author

I've tested and confirmed that this only works on markers. If there is a way to do it with a polygon I can always just make a transparent polygon to do it with.

@Pugglewuggle
Copy link
Author

Pugglewuggle commented Mar 3, 2017

Or, is there a way to toggle marker visibility but still have the fit to marker bounds work? Or should I just use a custom icon with a transparent 1x1 png for the bounds markers to mark each corner?

@Pugglewuggle
Copy link
Author

Well, this actually doesn't work very well (the invisible marker method) because I have markers that exist slightly outside the bounds box - since the fit to bounds doesn't actually set the view port of the map to the same as the bounds box - it adds padding.

@Pugglewuggle
Copy link
Author

Pugglewuggle commented Mar 3, 2017

This is what I'm looking for - the ability to define custom bounds to the map.

var latlngbounds = new google.maps.LatLngBounds();
			for (var i = 0; i < cwc2011_country_data.length; i++) {
				for (var j = 0; j < cwc2011_country_data[i].latlngs.length; j++) {
					latlngbounds.extend(cwc2011_country_data[i].latlngs[j]);
				}
			}
			map.fitBounds(latlngbounds);

@Pugglewuggle
Copy link
Author

I got around this by using the Google JS API calls instead of doing it through this control. This functionality would still be nice though.

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

2 participants