Is there a list which describes which map features in OSM is displayed per each zoom level? - openstreetmap

I found this list of map features but there is no indication when they are displayed.

The OpenStreetMap website does have a map key (accessible through the "i" icon on the right) that changes based on your current zoom level.
However, this list of features is incomplete. I believe the only reliable source of truth are the style files in the openstreetmap-carto repository (essentially the source code for the standard map style on osm.org). There, you'll find statements such as
[feature = 'amenity_parking_space'][zoom >= 18] {
line-width: 0.3;
line-color: mix(#parking-outline, #parking, 50%);
}
which tells you that individual parking spaces appear at zoom 18 and greater.

Related

VSCode API: Access the minimap

Is there any way to access the "minimap" that optionally appears next to the scroll bar on the right hand side of the editor?
Preferably I would like to access that panel's width in pixels.
The best I could do to get the values I want is to read the current editor configuration (also settable from the vscode settings UI/JSON).
const editorConfig = vscode.workspace.getConfiguration('editor');
const minimapOn = editorConfig.get("minimap.enabled");
const minimapWidth = editorConfig.get("minimap.maxColumn");
But this only lists the maximum width, not the current one.
Configuring the Width of the Editor's Minimap
The Minimaps with is configurable, not by pixels, but by characters.
The reason it is configurable by characters is because it gives developers a way of setting the minimap's width to the exact width that there longest lines of code are. This is beneficial, as it makes the minimap as wide as needed, without taking up any unnecessary space.
Below is the setting that changes the width of the editor's minimap.
// #file Globally Scoped "settings.json" file
{
"editor.minimap.maxColumn": 75
}
75 can be set to any amount of characters you choose.
Now the part about the API
Anytime you have a setting that does what you want, you can use the API to apply it to your extension. I don't want to continue explaining anything byond the scope of this question, so I will provide a link to the documentation that covers the method used to change a setting using the VS Code API, and a snippet showing you how to use the method to change the minimap's columns width.
Below shows the code an extension might include to change the size of the minimap.
await vscode.workspace
.getConfiguration()
.update(
'editor.minimap.maxColumn',
100,
vscode.ConfigurationTarget.Global
);
NOTE: I wrote the example above off the top of my head. I know that the semantics are all correct, but you will probably have to play with it to get it to do exactly what it is your going for.
Here are a couple links to help you understand what your doing.
"vscode.workspace.getConfiguration()" This is can be interpreted as the base of program-interface that changes settings. From this part of the API, a few methods, objects, constants, and events extend, all of which are used to set, get, and mutate configurations within VS Code.
"The Configuration target" sets the settings.json file you are targeting. Global is a good bet, I prefer "workspace" (which is not the same as "workspace folder".

How can I change the color of one single road on a Mapbox layer that has hundreds of roads?

I have a network of roads displaying on a layer in Mapbox. On mouseenter of a given individual road segment, I want to change it's line-color. I'm able to successfully change all the roads together as a whole, but how can I target a single road segment and change its color?
I've tried things like this but haven't found much luck targeting an invidual road segment:
map.on('mouseenter', 'road-street', (e) => {
map.getCanvas().style.cursor = 'pointer';
let uniqueId = "road-" + String(Date.now());
e.features[0].layer.id = uniqueId;
map.setPaintProperty(e.features[0].layer.id, 'line-color', '#0099ff');
});
But this generates an Object Error
Layers like road-street in Mapbox Streets don't contain unique attributes (such as an ID) that would let you easily color them individually. However, they do have unique geometry (with some caveats: the geometry of an individual feature is not necessarily the whole road, or what you expect to find as "the road").
You can do something like this:
Create a separate source selected-road of type line
Create a separate layer selected-road of type line, connected to the source.
When the user clicks/hovers, update its geometry like this:
map.getSource('selected-road').setData(e.features[0].geometry)

Update leaflet baselayer properties with GoogleMutant

I have a google layer (baselayer) GoogleMutant and want to update its options. I try to
map.remove(google.layer)
//update the POI visibility
google.layer.options.styles.forEach(i=>i.stylers[0].visibility = "off")
map.addLayer(google.layer)
this updates the layer options but the Points of interest are still on the map. Is there any way to update the options and apply them to the baselayer?
Thanks
Here is an example with google mutant https://jsfiddle.net/benderlio/2m4c01w6/10/
There is a button "remove POI", and I want to remove all poi from current layer with leaflet API
Leaflet doesn't work changing settings on the fly. You have to remove the whole object and create a substitute.
Like if you need to change a layer, you have to remove it like:
roadMutant.removeFrom(map); // or
map.removeLayer(roadMutant);
And then create and add the new one:
roadMutant.addTo(map);
I created a fiddle to help the change based on yours. It still have bugs and somewhere to grow, but it's a base...

leaflet - manually cluster markers

I need to manually cluster/uncluster few markers on the map (not automatically by zoom)
is there a way to tell Leaflet.markercluster which markers to cluster manually and not automatically by zoom.
I tried manipulating the L.markerClusterGroup layer internal cluster._gridClusters and cluster._gridUnclustered which holds an array of all the zooms and markers/clusters in each.
but changing the objects seems to do nothing and not represented on map.
a solution example would be:
selectedMarkers = [marker1,marker2,marker3];
map.cluster(selectedMarkers);
map.uncluster(selectedMarkers);
please help.

Bokeh - How to use box tool without default selections?

I have built a bokeh app that allows users to select windows in data and run python code to find and label (with markers) extreme values within these limits. For ease of interaction, I use the box select tool for the range selection. My problem arises when repeating this process for subsequent cases. After markers are placed for the results, they are rendered invisible by setting alpha to zero and another case needs to be chosen. When the new select box includes previous markers, they become visible based on the selection. How do I override this default behavior? Can markers be made unselectable? or can I add code to the customJS to hide them after they are selected?
Thanks in advance for any help!
There are a few possible approaches. If you just want non-selected glyphs to "disappear" visually, you can set a policy to do that as described here:
http://docs.bokeh.org/en/latest/docs/user_guide/styling.html#selected-and-unselected-glyphs
Basically, for bokeh.plotting, pass
nonselection_fill_alpha=0.0,
nonselection_line_alpha=0.0,
as arguments to your plot.circle call or whatever. Or if you are using the low level bokeh.models interface, something like:
renderer.nonselection_glyph = Circle(fill_alpha=0.0, line_alpha=0.0)
But be aware (I think you already are) that the invisible markers are still there, and still selectable if the user happens to draw a box over them with the selection tool.
If you truly want only a subset of the data to be visible and selectable after a selection, I'd say you want to replace the data in the column data source wholesale with the subset in your selection callback.