Find near me
I'm looking for a worklow that will find the closest features based on the user's current location or an entered address. Anyone had success with something like this?
0
-
You should somewhere configure the layers to search in. And I think also a maximum search distance. 0 -
I'm not sure what you mean by "configure the layers to search in" but my question may be unclear. I'm basically looking for a worklow where a person can hit a button and the results tab will show parking features near them based on their GPS location. 0 -
I'd like to do that too. Please post a solution if you find one :) 0 -
I believe Nico was suggesting you make the parking features identifiable, and in the workflow you would do a buffer for which you would need to set the distance. I'm not particularly experienced worth workflows, but if there is an activity to grasp the current GPS and use that to create a new feature, and then have it buffer at a set distance, and have it return the parking features. 0 -
Auto-correct uncorrected! :) 0 -
Here's a sample workflow for getting the user's location and buffering it: 0 -
Thanks, John! I was able to get it working using your example but now I'm looking to sort the features based on their distance rather than the default (which I believe is OBJECTID). 0 -
Hmm, that's a tricky one. The only way I can think of to do that would be to create a custom geoprocessing tool, but I've never tested using one in GE. 0 -
No need to execute a geoprocessor. Iterate your feature set, use the Distance function in the Geometry Service to calculate your distance, append the result to a new field, then sort your Feature Set. We've done this for a report years ago, I would need to dig to find the workflow. I will see if I can find it after I catch up this morning. 0 -
Tom, 0 -
Scott - I took John's workflow and expanded on it a bit. You can get it at https://github.com/DigitalDataServices/samples/tree/master/FeaturesNearMe 0 -
Tom, 0 -
I think it is. I checked my code and it is. - After the Sort FeatureSet, add an Assign function - Initial a string variable with a table header like "| Name | Distance |" + Environment.Newline + "|------|----------|" - Create a For Each loop just like before but loop through the sorted features and extract out the Park name and distance using md + Environment.Newline + "|" + item.Attributes("frstdivlab").ToString() + "|" + item.attributes("DISTANCE").ToString() + "|" - Display the FeatureSet in an Alert or since the example above is a Markdown table, in the Form Display.
_img_ alt="User-added image" src="https://latitudegeo--c.na53.content.force.com/servlet/rtaImage?eid=90760000000TV3B&feoid=Body&refid=0EM60000000M1wn" _/_img_0 -
It's throwing an error with this. 0 -
Did you create a variable md = string? 0 -
Yeah I think I set it up correctly. 0 -
Change the two Assign's to AssignInitMD and AssignAddMD. It may be that you didn't change the attribute field name? 0 -
Same error. 0 -
No, rename the modules to identify which one is throwing an error. My guess is that it is the one in the ForEach loop. What is the assignment in there. Change the variables back to "MD" 0 -
AssignInitMD + Environment.Newline + "|" + item.Attributes("frstdivlab").ToString() + "|" + item.attributes("DISTANCE").ToString() + "|" 0 -
Scott, you need to change "frstdivlab" to "YOUR_PARK_NAME_FIELD" 0 -
"NAME" 0 -
That fixed it. 0 -
double-check the assignment. there should be a list. It looks like you are just displaying the last. This is what the assignment in the ForEach loop should look like: MD + Environment.Newline + "|" + item.Attributes("NAME").ToString() + "|" + item.attributes("DISTANCE").ToString() + "|"
0 -
Yeah I had a typo from when I tried the other variables. I can generate a list, but thos definitely isn't in closest order based on where I clicked. Is the number supposed to represent the distance from where I clicked? 0 -
Yes. That is a projection issue. I am assuming your map is in Web Mercator which will also be the projection that the usrGeom will be in. Whereas your service is in 3361 (State Plane). Return the query results in whatever projection your web map is in. 0 -
That was it. Thank you so much for going above and beyond and walking me through that. 0 -
Yes, and you can use the Cast <T> activity for tha purpose. 0 -
What would the syntax on that look like? Here's what I have and it's throwing an error. 0 -
Switch the two variables in the Cast activity. usrGeom = location
Just as in an Assign activity the output is on the left side.0
Please sign in to leave a comment.
Comments
40 comments