I have a question. Is it possible to know that a specific coordinate (for example the coordinate of the BlueDot) is located over a particular space on the map? I cannot find a method to check if a coordinate is located on top of a space. I already know that it is possible to check a distance from a coordinate to a space but what I am looking for is a function to check if a coordinate is located on top of a space.
Currently no, this isn’t possible today. As you’ve found, you can get the distance from a coordinate to a space. If that value is 0 or very low, you could assume the user is in that space.
This is something we have on our roadmap for a future SDK release.
The way you tell us to find out if a coordinate is on top of a space is very inaccurate, since it might be possible that the center of space A is more far away than from space B, yet you are still located on top of space A.
We are developing an App for Airports using a WebView, each POI has a setting in the description that tells if the POI is located in the public or in the restricted area of the airport. We now want to know if the current BlueDot coordinate is within the public or restricted area of the airport, so we can draw the route to the selected gate accordingly. If we would know that a coordinate is located on top of a space, we could mark the spaces description to being in the public or restricted area of the airport. Since it is not possible to know if a coordinate is on top a specific space, it is difficult for us to determine in an accurate way that the BlueDot is within the public or restricted area.
Do you have any ideas how to solve this?
Does for example the function MapData.Query.nearest() return the nearest POI how the crow flies or the nearest POI from a coordinate directing through the actual route to the POI? If it is the route than it might be possible to know if a the coordinate is located in the public or restricted area by looking at the nearest POI by route and then inspecting the POIs description.
Please note that we are not able to calculate the nearest POI by route using the mappedin MapData.getDirections function since this function is very, very slow and we have many POIs on the map.
We just released an update to Mappedin JS today that may help to solve this.
There are new .geoJSON
properties for the map data classes, such as Space.geoJSON. These return the geomety of the space in GeoJSON format. You could use this along with turf/boolean-point-in-polygon to determine if the coordinate is within a space.
Hello, thank you for your answer. We tried to update our map to the most recent Mappedin JS beta version (6.0.1-beta.26) but now there is an error thrown when adding the map to the WebView:
Failed to initialize map: Error: Each LinearRing of a Polygon must have 4 or more Positions.
at Vu (chunk-2Z2ZUYZ5.js?v=95e8e8e3:2447:13)
at chunk-YVJD6MQT.js?v=95e8e8e3:12824:51
at Array.map ()
at Md.hideLayersIntersectingPolygons (chunk-YVJD6MQT.js?v=95e8e8e3:12824:40)
at xy.hideOutdoorLayersIntersectingPolygons (chunk-YVJD6MQT.js?v=95e8e8e3:13204:38)
at chunk-YVJD6MQT.js?v=95e8e8e3:16338:49
at new Promise ()
at Xc.addMap (chunk-YVJD6MQT.js?v=95e8e8e3:16316:12)
at Ha.addMap (chunk-YVJD6MQT.js?v=95e8e8e3:16550:23)
at NI (chunk-YVJD6MQT.js?v=95e8e8e3:16797:18)
This error was not shown in the prior Mappedin JS version we had in use (6.0.1-beta.19). How can we get rid of this error?
It looks like the following code throws this error:
const mapView = await show3dMap(mapContainer, mapData, {
initialFloor: "m_f2786e5df102b3c5",
shadingAndOutlines: false,
outdoorView: {
enabled: true,
// layersHiddenByGeometry?: string[];
style:
"https://tiles-cdn.mappedin.com/styles/starlight/style.json",
// token?: string;
},
});
Please send me the Map ID that is triggering this error for investigation. You can send it to me directly if you do not wish to post it in the forum.
Thank you for reporting this. We are in the processing of releasing Mappedin JS 6.0.1-beta.28, which fixes this issue. Please upgrade and let me know if you have any further issues.
Thank you, we have upgraded to the latest Mappedin JS version and with your help created a function to check if the coordinate is located on top of a space. We tested the function, it works and the performance is fast aswell.
Excellent, that’s great to hear. Thank you for sharing your results.