I have a MarkerClusterer which i want to disable if the zoom level is below a threshold.
Example:
The zoom level is 10, the clusters are visible. The threshold is 5, so if the user zooms out to see the world, all Markers should not be rendered. I don't want to clear the markers though, because they need to be shown if the user zooms in again.
If you don't want to clear the markers, you can instead use setMap() to set the map, to which the MarkerCluster is assigned, to a different map than the one the user is viewing.
setMap() takes null as a valid parameter.
Another option is to do some awful hack, like creating a second map that is not visible to the user and assigning the MarkerCluster to that map. It won't win any coding competitions, but it will work.
Then, when you get back to an appropriate zoom level, you can use setMap() again to put the MarkerCluster back on the map.
You can use the zoom_changed event to detect when the zoom on the map has changed and call setMap() appropriately.
Hopefully, this is all you need to get this done, but if not, post some of your code and maybe we can try to be more specific about exactly how to modify it to achieve this.
Related
I have added some drawing tools to my Mapbox map using the following code provided on the Mapbox website... https://docs.mapbox.com/mapbox-gl-js/example/mapbox-gl-draw/
I removed anything to do with the area measurement calculation as I only wanted to be able to draw on the map.
However, the map is set to default draw without having to click the drawing icon. This means when the page opens rather than being able to pan around the map the cursor is a crosshair and begins drawing.
I noted the following section in the script but not sure what to put in place of "draw_polygon" to stop it from being the default.
// Set mapbox-gl-draw to draw by default.
// The user does not have to click the polygon control button first.
defaultMode: 'draw_polygon'
});
Anyone have any ideas how to stop draw polygon from being the default?
Also any other ideas on other/better drawing tools?
The default mode is simple_select, so you can either add this in place of draw_polygon, or just remove the defaultMode option altogether and it will start in simple_select mode.
I have a Googlemap with multiple markers on that I refresh when moving around or zoom in/out the map. So far so good. The problem is that if a marker is refreshed, I mean repainted on the map, then it blinks for an instance, as it first gets deleted as an old marker and then painted as a new marker. I use setMap(null) to hide markers. Is there a way to avoid this blinking? Is there a way f.e. to add easingout effect at setMap(null) using jQuery or something?
Write your code to not do that. Don't delete all the existing markers, only delete those that no longer appear in the updated data and add new ones.
QUestion
I'm trying to show a google map with markers and a list refering to those markers next to it and link each list item with a the markers on the map.
So When I hover over link 1, the map should move to marker 1 on the same map. When I hover over link 2, the map should move to marker 2 on the map.
Findings
I found a solution very similar to what I want, but I cant seem to figure our how to call the funciton moveMarker( map, marker ) on hovering a link.
You can see a working JS fidde here : API Fiddle link
Can you guys please give me some thoughts?
How I've done this before is, have a global array of markers. Have your links numbered 1..x. Pass that number into the moveMarker function to indicate which marker is being hovered (or figure it out from the ID of the link). Use that to determine the position of which marker in the array to move to.
Also from your code snippet it seems map is a global variable (you don't do var map in your initialize function), so you shouldn't have to pass that in as an argument to moveMarker.
I'm using this third party library, called Marker Clusterer with the Google Maps API. http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/docs/reference.html
I am trying to trigger an event when the map's zoom level is changed. The odd thing I've noticed though, is that when you click on a marker cluster, it calls the zoom event twice. Has anyone come across this odd error before? Why would it trigger the zoom callback twice? When I zoom normally without using clusters, the zoom callback is only called once.
Any ideas?
Looks like that behavior is a fix for an issue on IOS. You can download your own copy of the code and remove the additional call to fitBounds if you don't need it.
I am hoping someone can point me in the right direction. I have a google map v3 with fusion table that I am looking to create a custom box with the content that would normally be displayed in an infowindow.
Much like http://www.instaearth.me or
http://chrismcaleenan.com/map/?page_id=7
So the user clicks on the marker and the content is loaded into a box/window/div that is not attached to the marker itself.
Does anyone know of any samples / tutorials where someone shows this being done.
Thanks
The FusionTablesLayer has a FusionTablesMouseEvent which is returned on a click (if you add a click event listener to the FusionTablesLayer). That Object contains the data in the row associated with that geographic object (icon, polyline or polygon), and you can use it to populate an HTML div on your page.
working example, zoom in past zoom level 2 to see the FusionTable code work, at zoom 0, 1 it uses the KmlLayer