Hi all
I'd like to be able to click near, but not directly on our street feature (line) layer and it return the street reference number from the nearest street in that layer.
We've got a number of public facing maps that are used to report issues that are not directly on but are near a street such as in a verge or a hedge etc. Our back office system needs the nearest street to the issue and currently we ask the customer to search for the nearest street and enter it manually into the form.
I've had a look through all the guidance and on here but I'm not sure where to get started with it. I don't think a 'locator' for reverse geocoding will do the job, I just need to interact with the nearest feature.
Here is an example of a map that I would update to include the nearest streets reference number.
https://codepen.io/RFletERYC/full/RwyYvBe
As you will see you can click anywhere on the map and it returns the X/Y coordinates which are then fed into our back office system. You can interact with the street layer too. But how do I pick up the details of the street when I'm not directly interacting with it?
Thanks in advance. Ricky
I have not done this, but it looks like you could use the geometryEngine nearestCoordinate to get the location on a feature. Then you could use the coordinate from the NearestPointResult object to query your feature layer for intersecting geometry.
Edit:
Since you will probably have to input the geometry of all features for the nearestCoordinate, you might as well reuse those with the geometryEngine again with intersects (iterating over all features) instead of querying the feature layer.
Thanks for the helpful pointers Blake.
I've also not done this before and being fairly new to JS it looks beyond my current skill set to write it from scratch. Using your links above, I'll see if I can find a sample that's doing roughly what I'm after and adapt that to my means.
Wish me luck!