How to control what markers are displayed by mapbox-gl-js - mapbox-gl-js

I am loading a bunch of geojson points. I can see that I am loading about 40 points but which ones get displayed on my map seems random and somehow connected to the zoom level. Below you can see that only 2 points of ~40 are displayed.
What criteria does mapbox-gl-js use to decide what to display?
Is there a way to control what points are being displayed? (All of them? Some based on an attribute?)

This is likely occurring because you are using the default text-allow-overlap value of false. The text-allow-overlap documentation reads
If true, the text will be visible even if it collides with other previously drawn symbols.
Because your symbols overlap each other, some are hidden. You can disable this behavior by setting text-allow-overlap to true.
You might find marker clustering to be useful.

Related

MapBox. A highlight effect by hover event on table. SetData takes 2s for updating source with 6000 features

I'm trying to implement a highlight effect by hover effect on the table's row. I've got the data table related to Mapbox's point features. I update the map point's styles by my rxjs state (every change in the state calls styles updating on my map). For small features count, it works well, but it takes 2 seconds for updating styles on the map with 6000 points. Directly setData execution takes 150-200 ms, but rendering takes 1-3 seconds. How can I improve the performance of the Mapbox for my task? As I wrote, I have 6000 points on the map, and when I hover the cursor over a row in the table I want to change the style for2 points. Change of style implemented by changing the feature's layer (might that be the matter?).
Thanks for any ideas.
the github issue.
setFeatureState is the most efficient way to update the styling of a small number of features on a map with many features.
It does have certain limitations: it only works on layers with feature IDs, and not all styling can be controlled through feature state (notably, layout properties such as icon-image cannot).
Documentation here: https://docs.mapbox.com/mapbox-gl-js/api/#map#setfeaturestate
I found more productive way to highlight any resource. I just use another data-source for selected / highlighted resources and one or few style layers. You only need to put selected resources to another data-source and draw them according selected style. That don't affective to common data sources, and don't need to recompute resources states, just draw selected resource above based resources.

Is there a way to check for markers whos icons intersect / overlap visibly?

I am building a map and want to use the leaflet markercluster plugin to cluster any markers that intersect visibly (the icons overlap each other). I can't seem to figure out a way to check whether the markers icons intersect though.
I've examined the documentation and the Marker objects. The marker object has no "bounds" object and has no function to return the bounds of the icon.
Yes, it's possible.
This is implemented in some Leaflet plugins, like Leaflet.LayerGroup.Collision - the technique involves fetching the computed style of each icon's HTML element to get the actual size in CSS pixels, offset those numbers by the relative pixel position of the marker's LatLng, and using a rtree data structure to speed up the calculation of the overlaps. Do have a look at the complete source for LayerGroup.Collision plugin.
Note that this technique only takes into account the rectangular bounding boxes of the icons; while it would be possible to check for the individual transparent pixels, that would involve more complex data structures and a different technique to fetch the opacity of each pixel.

tableau adjust marks size using number

In Marks, click Size and there pops a slider where I can adjust the size of a shape. But how to accurately control the size, is there some property with numbers to accurately control it? I have two sheets to show something similar and I want to display exactly the same sized shapes.
If you want to ensure 'sizes' are the same across two worksheets, I'd suggest snapping the 'size' setting to the center on both, as this is the easiest option to select. You can then use a measure to set the size, if this is desirable, and then the difference in size will be relative on both worksheets.
There isn't a numerical value override for the size slider.
Ben is correct, there isn't yet a numerical value override for the slider. You can use parameters with Min/Max/Sum etc. and a variable to somewhat change the sizes but they have to have multiple entries per line. It is unfortunate that Tableau still doesn't get that people want both a 'relative' sizing system that uses numbers from the dataset and a 'static' sizing system that allows for shapes to be set to '11px' or something along those lines. Yes, you can control that kind of in the dashboard with a vertical and fill entire box etc; but that doesn't address the very real scenario where you want a user to be able to re-size on the fly. Just my two cents.
I ran into this today. Very annoying. Need to keep shapes the same size across all worksheets and therefore same on dashboard.

Is it possible to give different icons to a cluster group when it starts unclustering?

The red circles with numbers are clusters, but part of a bigger cluster when zoomed out.
Is it possible to change the marker/icon of the marker cluster in this present zoom depending on the markers that they have inside them? This without clicking them or anything, just change depending on the values of the markers that are hidden?
I have tried accessing the layer that is clustering all of them but I haven't been able to find the markers themselves, much less know how it would be possible to change the appearance of one without changing the other.
It looks like you already know how to customize your clusters appearance.
In the case your question refers only to the number of contained markers, you would just need to use a slightly modified version of the default iconCreateFunction to adjust the threshold values. When markers are removed/added from the MarkerClusterGroups and a cluster is de-/populated in consequence, its icon is re-drawn automatically. Customising the Clustered Markers
Now if you want this appearance to depend on some data from the contained markers, you would simply need to use cluster.getAllChildMarkers(); within your iconCreateFunction to get the array of markers contained within the cluster being styled. Then iterate through that array of markers, look for your data and create an icon accordingly.
Then, I understand that some data attached to your markers is changing, without any user action, and you want your clusters to update their appearance in consequence? In that case, please refer to this related question to upgrade your markercluster plugin with the new refreshClusters() method.
If your iconCreateFunction is properly designed, you do not have to worry about which clusters are changed. In fact, ALL clusters can be re-drawned, but if their markers data has not changed, they will get the same icon.

Leaflet.js display of a non-geo map (gdal2tiles.py) – I need a concrete example

I'm displaying a map that's been tiled (-p raster) using gdal2tiles.py. The X-coordinate is about [0..-1160]. The Y-coordinate, for some reason, is [-700,0]. Zoom-levels 0-5.
I simply cannot get a plausible display to work. Sometimes, if I zoom-out to level-zero, I see the map way down at the bottom of the display ... not centered. Nothing at all appears at other levels.
I am also seeing the display "bounce back and forth" between about a 3-o'clock and a 6-o'clock position. (Only, once again, at zoom-level zero.)
I am at my wit's end. Please give guidance. Complete examples. Anything ...
Well, I found my answer:
If you're going to be using several layers in your Leaflet map, add them in the constructor-call, using the layers parameter.
If you try to do things with the layers before joining them all together, or with the map with no layers added, "strange and default things will happen." (For example, although I requested the Simple CRS when constructing things (separately...), the net-effect was to actually try to use a different one. Therefore, "do what the author expected." Specify all the layers at once, to the Map constructor. Then, customize them as you need to. Make very sure that they all know about each other from the very start of things.