Enabling location functionality in an image-map/SVG file

1776
6
03-01-2021 09:58 AM
TLandrum
New Contributor II

Hi!

I would like to have a question in my survey that populates a Station Number field when the user clicks on an image-map. The catch is that I would like for the image-map to show the user's location so that he/she knows where to click in the image-map to capture the most accurate Station number. I realize that the image-map would need to be subdivided into areas that represent the minimum accuracy that needs to be captured.

Another option may be to create a custom base map that visually includes the stationing info (lines or polygons/labels) and use it in a geopoint question. When the user hones in on their location, they should see the Station Number and then can manually enter it into a text field. I was trying to avoid having them manually enter the Station Number so this solution is not ideal.

I like the idea of using an image-map but if there's no way for the user to know where they are located on the image map, I don't think it will work. Any other ideas?

Thanks,

Teri

6 Replies
BrettStokes
Esri Contributor

Hello!

You're right, the image-map appearance is not designed to maintain any spatial references and cannot display a location. You could definitely implement your second option (with custom basemap to help users identify the appropriate station number) but I think a point in polygon Javascript function sounds like a better solution. This would require you to have a polygon feature layer that contains the Station Numbers and would autopopulate the form based on the user location. You could hide this completely, make it read only, or allow users to change the Station Number manually if they needed to.

To get started, I recommend having a look at the 'JavaScript' sample in Survey123 Connect. It contains a group named "Working with a Feature Service" with an example. The example uses World Admin Divisions as the polygon layer (the URL for this can be changed to your Station Number polygon feature layer) and then shows a few different pulldata() functions for returning different components of the response. You will be able to easily adapt this to suit your feature layer.

Hope this helps,

Brett

0 Kudos
BrettStokes
Esri Contributor

BrettStokes_0-1614634763597.png

 

0 Kudos
TLandrum
New Contributor II

Hi Brett,

It took longer to generate the station polygons than I expected. Now that I have a working draft that I have published as a hosted feature layer, I am getting a Token Required message when I try to use the URL that I copied. I tried finding a solution (which led me to using a debugger) but I was hoping it was more straightforward. Can you provide some insight into how I can generate a proper URL?

Thanks,

Teri

0 Kudos
TLandrum
New Contributor II

Sweet! That's a great idea! I knew that someone out there had to know of a better way to accomplish this. I will give it a shot tomorrow and let you know how it goes. Thanks for all the details as well. Hopefully I can get it half way working for my draft demo on Wednesday. I'll "accept as solution" as soon as I can tell it's going to work. Thank you so much, Brett.

0 Kudos
TLandrum
New Contributor II

Hi @BrettStokes 

As mentioned in my comment below, I encountered an issue with the token. I have discovered that if I pass the token that gets generated when I access the feature service, I can get the code to work. I imagine this token is unique to me or gets regenerated so hard coding the token isn't a solution ... or is it? Here's screenshot of where I am at. By the way, I created a test polygon at my current location for convenience while testing.

TLandrum_1-1615298380700.png

 

 

0 Kudos
BrettStokes
Esri Contributor

Hi Teri,

Sorry for the delay in my response. The issue you're encountering sounds like a log-in/sharing problem. Can you please check that your hosted Stations Polygon feature layer is shared with your user account and that you're logged in to Connect while testing this. Alternatively, you could share the feature layer publicly if that is feasible for you.

I've attached a XLSForm example of the edited 'Javascript' sample that is pointed to a publicly shared post code polygon feature layer (https://services1.arcgis.com/e7dVfn25KpfE6dDd/arcgis/rest/services/Post_codes/FeatureServer/0). It uses the same javascript function as the sample, so you should be able to create a new survey based on the .xlsx file (just copy the 'url_requests.js' file to the 'scripts' folder). Note that the feature layer only contains post codes from the state of Victoria, Australia. You will need to place a point somewhere in Victoria to get a valid response:

BrettStokes_0-1615500717737.png

 

0 Kudos