My map pushpins are relatively close to each other and even on a big zoom I still see them clustered.
I solved this issue by spreading the clustered pushpins by some random distance 5-10 meters.
I need more accurate solution so my idea is to disable the clustering below the certain zoom level, but I didn't find any way how to do it.
There is no option to disable clustering in the clustering layer in Bing Maps, but what you can do is monitor the zoom level of the map, and when it gets to a certain point, hide the cluster layer and load a new layer that isn't clustered. Unfortunately this means having two copies of your data in memory.
If you haven't fully committed to using the Bing Maps platform, you may also want to take a look at Azure Maps. The Azure Maps web SDK does things a bit differently where you would keep your data in a single data source and attach rendering layers to it. Clustering is turned on in the data source and has a max zoom level option for clustering.
Here is some examples: https://azuremapscodesamples.azurewebsites.net/index.html?search=cluster
Here is documentation: https://learn.microsoft.com/en-us/azure/azure-maps/clustering-point-data-web-sdk
There is an option clusteringEnabled now on ClusterLayerOptions which will disable clustering without losing the whole layer.
eg:
Microsoft.Maps.Events.addHandler(this.map, 'viewchangeend', () => {
// de-cluster at highest zoom level
this.clusterLayer?.setOptions({
clusteringEnabled:
this.map.getZoom() < this.map.getZoomRange().max
});
});
Related
I'm new to leafletjs. Been working on cesiumjs for a while and we are trying leaflet now. The main reason for the switch is to see if there's a huge performance difference.
In Cesium, I had a collection of primitive points that I plotted. What's the most efficient way of plotting 140K points in leafletjs? Using markers or creating individual little circles?
I am also thinking of using the clustering plugin (http://leafletjs.com/2012/08/20/guest-post-markerclusterer-0-1-released.html), so please share any thoughts on performance.
You have 2 common options:
Display your points in a Canvas-based layer, like using Circle Markers and force rendering them on a Canvas instead of SVG (see also Leaflet MaskCanvas plugin). Circle Markers, even on a canvas, still emit events, so you can detect "click" etc.
Use a clustering plugin, like Leaflet.markercluster plugin that you mention for exampe. It can handle your 140k points, depending on the client's computer performance (see https://github.com/Leaflet/Leaflet.markercluster#handling-lots-of-markers and demo http://leaflet.github.io/Leaflet.markercluster/example/marker-clustering-realworld.50000.html with 50k points, but note that the demo uses an old version of the plugin, whereas the current version is even faster).
Trying to display your 140k points without Canvas or clustering will crash your browser for sure.
If you want to render more than 100k markers, you can use Supercluster library, because Leaflet.markercluster loading of >100k markers could take more than 30 seconds.
I created a github repo to compare initial loading of Leaflet.markercluster and Supercluster.
everyone. Recently, we have faced one problem about the speed of loading google map components on different broswer. Regarding to the function , we have added 120 polygons, 360 sector ( also polygon ) and several attributes which attach to components on the map. The verson of JS tool is Google Map Javascript V3.
Now, this module is running fast and smoothly on Chrome and Foxfire broswer. HOWEVER, terreble problem would occur on IE8 or IE9. The process about loading informations into map becomes very slow, also during the period of dragging or zooming the map, which can not be accepted by users.
So, is there any solution about acceleration in this situation ?
Thank you very much for any reply !
In my experience it's just IE being IE.
I would suggest scaling down the number of polygons you need to show at one time by using the map bounds as the criteria to filter by. You'll still end up running into issues if you let the users zoom out to show the whole map so you may want to limit zoom levels as well.
If you take all the points that make up your polygon and push(extend) them to a LatLngBounds you can grab the bounding box and check to see if the center of that bounding box is in the map's current bounds.
I'm displaying many (hundreds) of markers at a time in a given viewport in Google Maps. Often, this leads to markers being drawn over each other.
Since the exact positions aren't as important at zoom levels where so many markers are drawn, is there a library or piece of code that allows markers to dynamically update their position based on whether they are overlapping with other markers or not? As the user zooms in (and markers becomes more sparse), the markers will then move closer to their real positions.
And yes, I know about groupings, marker clusterings, etc. Those solutions aren't appropriate in my situation, since it is important that all markers be displayed at all times. And in actuality, I am already using those techniques as well, where appropriate. I'm using the Javascript V3 API.
You probably need to implement your own clustering algorithm - I think Google Maps let's you implement your own strategy (I know Bing Maps does, and typical they copy each other within 6 months or so of a new feature being implemented).
Note that for lots of dense pushpins, your constrains of separation but displaying all pins, are in conflict.
as for a strategy, my first thought is an annealing type of algorithm, although it probably isn't very fast. Basically each pushpin would exert a force on surrounding pushpins within a certain distance. iterate until sufficiently stable.
Does the CloudMade API have the ability to control the z-order or z-index of the marker overlays (e.g.icons)?
I have used this before in Google Maps to make certain icons with more importance draw over the top of other icons with lesser importance (especially in some zoom levels where they may bunch together).
The Google Maps GMarker has the zIndexProcess option to handle this. Does anyone know if CloudMade has this facility? I have scoured the API docs and found nothing. Or does anyone here perhaps have an ad-hoc method that ensures one marker (or group of makers) will be drawn on a layer above the other?
Currently this feature is not available at CloudMade, but I'll add it to our Feature Requests list..
We started using Google Maps on our web application rather extensively. It worked fine at the beginning, but as we add more markers we find that the performance are not quite there. Although I'm quite sure we don't use it in the most efficient way.
I am looking for information about Google Maps best practices and tips'n tricks. Any suggestions?
You might find some good ideas in this article, which compares several methods of handling large amounts of markers.
Marker Manager has some limitations, depending on what you're trying to accomplish; for instance, it doesn't allow every marker to be available from every zoom level. I created a clustering function based on the principles discussed in this tutorial. It uses the Static Maps API in PHP, but the principles behind the clustering can be used however you want.
Update: This clustering utility was just released: MarkerClusterer
Use Marker Manager.
Limit markers to what's visible (ie, understand the window boundaries, and only show markers that fall inside the window)
Learn to listen for various map activities and react - such as viewpoint moves, zooming, etc - to update the markers
Don't show markers that overlap significantly - show only one marker (perhaps a different shade or color to denote there are several points at this marker) and let the user zoom in if they want to see the individual markers. Use the tooltip to show a zoomed in window if you want to get fancy.