Google maps: Same positioned clustered markers disappear on zoom - google-maps

I'm currently using the MarkerClusterer v3 library in my app to group markers inside a Google map instance.
I've found that when I have 2 markers on the same exact coordinates, the clusterer displays a group of 2 markers correctly, but when clicking on the cluster to zoom into the 2 individual markers, no markers appear. Zooming back out re-paints the "2 marker" cluster.
I'm using the default Google Maps API, adding markers to the clusterer individually inside a loop. When I disable the clusterer I can zoom into the 2 markers properly.
Any thoughts on why this may be happening?

Finally found the answer:
Marker Clusterer accepts a parameter maxZoom that controls the maximum zoom to display clusters. If this value is too high (in my case higher than the possible zoom in that area) it won't display the markers properly.
Playing around with this parameter allows for fine-tuned cluster behaviour, as you zoom into your markers.

Related

How can I restrict google map from repeating in react-google-maps

I am plotting different markers on different locations on the map and then drawing polylines from markers to markers. since the map is repeating the markers are repeating as well and so the lines go in all direction in order to find the shortest path on the map.
Even if we optimize the markers, the markers won't repeat but the polylines are drawn weirdly if the markers are far apart from each other on the map.
Is there a way we can restrict map from repeating itself?
You should restrict minZoom to 1 and disable map movement on that zoom level.
Have you seen these SO answers?
Display world map with no repeats
Google Maps API V3: Bound world to fit area and disable map repeat

Google Maps Static API - Custom zoom with markers

I am creating an application that downloads images from maps using the Google Maps Static API. I would want to decide the zoom level when having markers on the map (right now the zoom is set automatically so that all markers are shown in the image). Does anyone know if this is possible?
Right now the zoom is set automatically so that all markers are shown in the image
You are halfway there. Once done, get the resulting the zoom level: map.getZoom();
However, I think your app violates Google's terms as it is forbidden to copy their content.
According to the documentation, you can use the center and zoom parameters to configure the map (they aren't required with markers):
Location Parameters
center (required if markers not present) defines the center of the map, equidistant from all edges of the map. This parameter takes a location as either a comma-separated {latitude,longitude} pair (e.g. "40.714728,-73.998672") or a string address (e.g. "city hall, new york, ny") identifying a unique location on the face of the earth. For more information, see Locations below.
zoom (required if markers not present) defines the zoom level of the map, which determines the magnification level of the map. This parameter takes a numerical value corresponding to the zoom level of the region desired. For more information, see zoom levels below.
example URL:
https://maps.googleapis.com/maps/api/staticmap?center=42,-72&zoom=5&size=400x400&markers=color:blue%7Clabel:S%7C11211%7C11206%7C11222&format=jpg
resulting image:

Google Maps Markerclusterer - Manually Set Zoom Level

I use Google Maps Markerclusterer and normally it works great. The problem I am having is when only 1 marker is being displayed (due to users choosing options resulting in 1 marker) the clusterer is setting the zoom level all the way in to the closest level.
Is there any way I can manually set my zoom level and still use the clusterer? I found the MaxZoomLevel feature but that doesn't actually control the zoom. Trying to set the zoom manually at initiate did not work either.
Thanks!

On my Google Maps when I zoom out beyond level 10 all my markers disappear

My google maps work fine at a zoom level higher than 10, but if I zoom out my markers disappear. I cant see where the error is. Have tried using v3 and v2. Also changing from .png markers to .gif. Have tried with fewer points on the map.
Its the same problem across all the browsers.
Thanks for helping...
http://test.onionring.co.uk/map-towns.asp?region=Cheshire
Nick
This is your problem (the marker manager is doing what you are telling it to do):
manager.addMarkers(batch, 11);
According to the documentation, 11 is the minimum zoom (the first zoom at which the marker will appear).
addMarker(marker:Marker, minZoom:Number, opt_maxZoom:Number)

Setting map bounds

I have a map which I would like to stay within certain bounds. I have allowed for 2 zoom levels 5 and 8. On zoom level 5 I was able to keep the map from moving by setting the center of the map to adjust by using the setCenter() function on the event of a drag. When I am zoomed in at zoom level 8 I would like to prevent users from dragging the map outside designated limits. The limits are the bounds at zoom level 5. I have tried a few things but with no avail. When I used fitbounds() it kicked me back to zoom level 5. I basically just want to limit how far you can go on the map. Any help would be appreciated.
G
There is a method posted here http://econym.org.uk/gmap/range.htm that works with v2 of the Google Maps API. The technique should work with v3 as well. View source on the example page.
Also see the duplicate question here for refinements on the above method: Google Maps API V3: limit map bounds