Select to view content in your preferred language

Using both geocode and press-to-locate on the same form

130
2
Jump to solution
11-22-2024 11:12 AM
BenSperry
Occasional Contributor

Hi,

Does anyone know how to get both an address search (geocode) and map selector (press-to-locate) on the same form?

I am trying to provide two different options for my residents to select a location. Either using the geocode search appearance which will let them type in an address or using the map selector. If I put both into the appearance field, then it defaults to just entering an address. If I try to use a calculation or reference a calculated value, then it defaults to press-to-locate. If I have two geopoint types in the same survey conditional on what the user picks I can't publish. I also can't have a repeat question to allow for two geopoints because this is built on an existing service. And I know that they can search for an address in the map but it is not as slick as the geocode address search so I would like to default to that if possible.

BenSperry_0-1732302567933.png

BenSperry_1-1732302659245.png

 

Any insight would be helpful.  

Many thanks 🙂

0 Kudos
1 Solution

Accepted Solutions
ZacharySutherby
Esri Regular Contributor

Hello @BenSperry

You'll need to do some trickery with the `null` bind::esri:fieldType. You can only have 1 geometry question submit data per layer so essentially you'll need to make questions null and then have another that calculates the geometry and is ultimately submitted. 

Based on your screen capture it looks like you're mostly there. Try setting Loc1 and Loc2 to null in the bind::esri:fieldType, change Location to a geopoint with a hidden appearance and don't set that field type to null. 

If you're interested you should also be able to change the Location calculation to coalesce(${Loc1}, ${Loc2})

Thank you,
Zach

View solution in original post

0 Kudos
2 Replies
ZacharySutherby
Esri Regular Contributor

Hello @BenSperry

You'll need to do some trickery with the `null` bind::esri:fieldType. You can only have 1 geometry question submit data per layer so essentially you'll need to make questions null and then have another that calculates the geometry and is ultimately submitted. 

Based on your screen capture it looks like you're mostly there. Try setting Loc1 and Loc2 to null in the bind::esri:fieldType, change Location to a geopoint with a hidden appearance and don't set that field type to null. 

If you're interested you should also be able to change the Location calculation to coalesce(${Loc1}, ${Loc2})

Thank you,
Zach
0 Kudos
BenSperry
Occasional Contributor

Hello Zach,

Thank you for your timely advice. Setting the extra geopoints to null indeed allowed me to publish successfully.

Here are a few notes for any readers who may come later:

  1. If you use the "geocode" appearance on a geopoint question, it will work in the Survey123 app, but not in the web form.
  2. To enable address suggestions in the web form, you must use the "geocode" appearance on a text question type.
  3. The coalesce function did not work as expected with the geopoint question. While it worked on other question types, it seems to be incompatible with geopoints—possibly due to the difference in data types.
  4. Alternatively, instead of calculating the location using text + geocode, you could simply expose both questions (text and geopoint) to the user to achieve the same result.

Here is my final working section:

BenSperry_1-1732558615117.png

 

Thanks again, Zach, for your help!

Best regards,
Benjamin

0 Kudos