Mapbox how to query for the features which are available in current view port? - mapbox-gl-js

I want to use mapbox's queryRenderedFeatures API which will give me the set of "visible" features satisfying the given query parameters.
Does this gives the feature set from current map viewport only? If not then how do I fetch the features from current viewport only?
Is there any way where I can provide x,y coordinate bounds of a map viewport to queryRenderedFeatures API?

Yes this gives the features from the current viewport only.
You can get a subset of those features by giving a bounding box with the geometry parameter. See the documentation for this functon.
Omitting this parameter (i.e. calling Map#queryRenderedFeatures with zero arguments, or with only a options argument) is equivalent to passing a bounding box encompassing the entire map viewport.

Related

Validate number sequence as quadkey (not just regex)

I know quadkeys have the basic regex of [0-3]{6,23}.
But is it possible for a number to match that regex and not be a quadkey?
I.e. random number 2010210202020021
Given a random number, I would like to know if it is a quadkey or not and I'd like to know if there's a way to check beyond just a simple regex.
Seems like the best way may be to convert it to a long/lat and see if that's a valid location? Is it possible to convert it like that?
In terms of quadkeys, that regex would always match valid quadkeys, however, if these quadkeys are valid in your map platform would depend on the platform.
Bing Maps typically supports zoom levels 1 through 19 (additional zoom levels in select areas, usually via birdseye imagery which doesn't use quadkeys). Note that Bing Maps uses raster tiles that cover 256-pixel squares.
In Azure Maps, many of the map tile services support zoom levels 0 to 22, and the map control itself can go down to zoom level 24 if you have custom map tiles. Note that Azure Maps uses both 256-pixel raster tiles, and vector tiles that cover 512-pixel squares.
For your regex, if you want to support all zoom levels you would need to adjust the numbers in the squiggly brackets.

AEM6.4: Meaning of values in image map properties

AEM offers a plugin to create image maps for its internal inplace editor. After configuration the given values are stored into follow forrmat:
[rect(89,92,356,368)"/content/sites/we-retail/us"|"_blank"|"fdfdfdfdf"|(0.2,0.2004,0.8,0.8017)]
The first paratheses are defines the coordinates of choosen shape.
The content within the first quotaion signs defines the target site, within the second how to open it the browser. In the third pair of quotations sign contains an alternative Text for non images display.
What I don't know are the values in second paratheses. Does someone know for what these values stands for?
From the WCM core components Image model, they are called relative coordinates.
They are not standard HTML attributes and are instead populated as data attributes of the area tag within the image component.
See code below:
<area shape="${area.shape}" coords="${area.coordinates}" href="${area.href}"
target="${area.target}" alt="${area.alt}" data-cmp-hook-image="area"
data-cmp-relcoords="${area.relativeCoordinates}">
Since the map coordinates are fixed coordinates and do not change when the image scales in or not based on screen sizes, the image component’s JavaScript uses this relative coordinates data to adjust the coordinates of the map area whenever the image size is adjusted. This is handled by the resizeAreas() function within the component’s clientlib.

Filtering polygons based on text input in mapbox

I'm trying to work out a variation on the mapbox code provided in this tutorial here: https://docs.mapbox.com/mapbox-gl-js/example/filter-markers-by-input/
But instead of filtering individual points, I'm trying to figure out how to filter polygons from a GeoJSON that have names appended based on an integer feature. Basically, I want to be able to enter the appended name of a polygon into a text box and have the map filter to just that polygon. I'm having difficulty identifying which parts of the code in the example to isolate and graft over. Has anyone tried something like this before?
When you say "filter to just that polygon", I think what you mean (in geospatial terms) is "filter to show only points within that polygon".
You will want to use Turf's "booleanWithin" function.
You will want to change this code:
layerIDs.forEach(function(layerID) {
map.setLayoutProperty(layerID, 'visibility',
layerID.indexOf(value) > -1 ? 'visible' : 'none');
});
You will have to iterate over the points themselves (not just their IDs), and use the booleanWithin function to check whether the point is within the polygon that you have somewhere else loaded.

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.

How do I query features above a certain height in OpenStreetMap?

I'd like to query all objects that are taller than 20m within a bounding box on OSM?
Is this possible so I can place them on a map or even generate a map tile with them drawn on it.
You can query Overpass API for all objects that do have a height tag in the first place and then filter the results yourself in any language that can process JSON or XML (Overpass cannot compare tag values with >).