Reputation: 498
I have an app whereby users select parcels of land based on shapefile information. How can I return the associated street polyline location (lat, long)? I want to be able to locate the center of the street and its extents in front of this parcel. Refer to the image below the parcel is in blue and the street polyline I am interested in is in red.
If I could be pointed towards which Esri javascript method or class I could use then I can figure out the rest
Upvotes: 0
Views: 144
Reputation: 5270
Assuming that you have a Road
FeatureLayer
, what you could do is to spatial query it using the parcel geometry. In order to do that you can use queryFeatures
method. You can add a buffer distance in order to get the roads that are around the parcel. Something like this,
let query = roadsFeatureLayer.createQuery();
query.geometry = parcelGeometry; // the parcel polygon geometry
query.distance = 10;
query.units = "meters";
query.spatialRelationship = "intersects";
query.returnGeometry = true;
query.outFields = ["*"];
roadsFeatureLayer.queryFeatures(query)
.then(function(response){
// returns a feature set with the roads features that
// intersect the 10 meters buffered parcel polygon geometry
});
Now, the result includes a set of roads. The decision of wich one you need, is another problem like @seth-lutske mention in the comments.
ArcGIS JS API - FeatureLayer queryFeatures
Upvotes: 2