Skip to main content

Find near me

Comments

40 comments

  • Nico Burgerhart
    You should somewhere configure the layers to search in. And I think also a maximum search distance.
    0
  • Permanently deleted user
    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
  • Permanently deleted user
    I'd like to do that too. Please post a solution if you find one :)
    0
  • Permanently deleted user
    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
  • Permanently deleted user
    Auto-correct uncorrected! :)
    0
  • John Nerge
    Here's a sample workflow for getting the user's location and buffering it:

     

    https://drive.google.com/open?id=0B_hHHiqcTKMfMmRLNUJlRnRkLXc

     

    It includes adding a markup geometry so you can see the buffer working, but you can remove it if you don't need it. Same goes for the Get and Set Extent activities.

     

    Once you have it working with your geometry service and desired buffer distance (or a user-provided distance), the next step is to use the unioned buffer geometry (resultGeometry) to run a Query Task and Select Features against your parking features layer. That should return results of all parking features within the buffer radius of your user's location.

     

    This is a basic sample workflow, but I recommend running as much of the geoprocessing in a separate sequence in a flowchart so you only pass the information you need to when running client-side activities.
    0
  • Permanently deleted user
    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
  • John Nerge
    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
  • Tom Neer
    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
  • Permanently deleted user
    Tom, 

     

    Thanks!  This is definitely helpful.  I'm still relatively new to alot of this so if you have a copy of that workflow that would be awesome.
    0
  • Tom Neer
    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
  • Permanently deleted user
    Tom, 

     

    This is awesome, thanks!  I have it running but it doesn't seem to be sorting by distance.

     

    You can see it here, http://gis.greenvillesc.gov/Html5Viewer/index.html?viewer=ParksandRecFinder.  It's in the I Want To menu.

     

     
    0
  • Tom Neer
    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
  • Permanently deleted user
    It's throwing an error with this. 

     

     

    _img_ alt="User-added image" src="https://latitudegeo--c.na53.content.force.com/servlet/rtaImage?eid=90760000000TV3G&feoid=Body&refid=0EM60000000M1x2"_/_img_

     

     

    _img_ alt="User-added image" src="https://latitudegeo--c.na53.content.force.com/servlet/rtaImage?eid=90760000000TV3G&feoid=Body&refid=0EM60000000M1x7"_/_img_

     

     
    0
  • Tom Neer
    Did you create a variable md = string?
    0
  • Permanently deleted user
    Yeah I think I set it up correctly.

     

     

    User-added image
    0
  • Tom Neer
    Change the two Assign's to AssignInitMD and AssignAddMD. It may be that you didn't change the attribute field name?

     

     
    0
  • Permanently deleted user
    Same error.

     

    Is this what you meant?  Should the second assign have double quotes around the right side of the expression?

     

     

    User-added image
    0
  • Tom Neer
    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
  • Permanently deleted user
    AssignInitMD + Environment.Newline + "|" + item.Attributes("frstdivlab").ToString() + "|" + item.attributes("DISTANCE").ToString() + "|"
    0
  • Tom Neer
    Scott, you need to change "frstdivlab" to "YOUR_PARK_NAME_FIELD"
    0
  • Tom Neer
    "NAME"
    0
  • Permanently deleted user
    That fixed it.  

     

    Now the alert is giving me the park that is farthest away.  Is it sorting by farthest to shortest?

     

     

    User-added image
    0
  • Tom Neer
    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
  • Permanently deleted user
    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?

     

    Maybe it's a spatial projection issue?

     

    User-added image

     

     
    0
  • Tom Neer
    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
  • Permanently deleted user
    That was it.  Thank you so much for going above and beyond and walking me through that.  

     

    One last question (hopefully), I'm modifying this for the handleld devices to use the current position task but I'm having but it's creating the variable as a ESRI.ArcGIS.Client.Geomtry.MapPoint and I think the Buffer Task wants it as ESRI.ArcGIS.Client.Geomtery.Geometry.  Do I need to add a step to convert it?  
    0
  • Nico Burgerhart
    Yes, and you can use the Cast <T> activity for tha purpose.
    0
  • Permanently deleted user
    What would the syntax on that look like?  Here's what I have and it's throwing an error.

     

     

    _img_ alt="User-added image" src="https://latitudegeo--c.na53.content.force.com/servlet/rtaImage?eid=90760000000PCxw&feoid=Body&refid=0EM60000000HRnI" _/_img_

     

     
    0
  • Nico Burgerhart
    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.