1

Topic: How to populate Spatial ref from Location autocomplete

I have a General Pupose Data Entry Forms / Sample with occurrences form on my Drupal 7 website.

The Form sructure looks like:

=Observer details=
[smpAttr:458]
[smpAttr:14]
=Record details=
[date]
@date:default=Select
[species]
[species attributes]

?Please provide a location for the record. You can enter the reference directly, or search for a place then click on the map to set it.?

[location autocomplete]
[spatial reference]
[map]
[sample comment]
=*=

1) How do I restrict the [location autocomplete] to only the sites defined in the warehouse Lookup list | Locations for my website?

2) Is it possible to populate the [spatial reference] when a location is selected? If not, what is the expected user behaviour?

Thanks, Chris

Chris Dee
Garganey Consulting

2

Re: How to populate Spatial ref from Location autocomplete

Hi

Does anyone understand what I am asking here? Do you need more information?

Thanks, Chris

Chris Dee
Garganey Consulting

3

Re: How to populate Spatial ref from Location autocomplete

Can anyone help me with this? I cannot find anything in the documentation.

Thanks, Chris

Chris Dee
Garganey Consulting

4

Re: How to populate Spatial ref from Location autocomplete

You are right – the default query run for a location autocomplete is to include publically available locations. On the test warehouse this means you’ll get a rather horrid mishmash of test data but even on the live you’ll want to avoid this. Probably the quickest way to achieve what you want is to pass a parameter called “extraParams” to the control, which provides additional filtering to the web service request the control sends. This is a JSON parameter, so you could add the following on the line after [location autocomplete], replacing n with your website. That will force out the locations which you are technically allowed to use, but don’t want.
@extraParams={"website_id":n}

There is an option @searchUpdatesSref you can apply to the location autocomplete which will achieve what you want for filling in the grid reference. This needs to be set to true.

John van Breda
Biodiverse IT

5

Re: How to populate Spatial ref from Location autocomplete

Excellent that is just what I needed - many thanks, John.

Just one follow-up question at the moment. With @searchUpdatesSref set, selecting a location from [location autocomplete] correctly scrolls and zooms the map, but if the user then changes the location by clicking elsewhere on the map, the [spatial reference] changes correctly, but the original site name is retained and gets stored. Is there a parameter that sets the location to a default 'other' value (or unsets it) when the user clicks in the map?

It looks like the instream Javascript indiciaData.onloadFns.push function is only triggering .change() on the field with id of srefId.

Chris Dee
Garganey Consulting

6

Re: How to populate Spatial ref from Location autocomplete

Hi,
I don't think there's any code written to clear the location if you click outside the boundary of a selected location. Potentially you could add your own JavaScript to the page to do this, but bear in mind there are cases (e.g. clicking alongside a river) where you wouldn't want to do this. I'd hope that if people select a site name they really mean it!
Best wishes
John

John van Breda
Biodiverse IT