Toggle menu

Location Picker

The location picker field uses Google Maps to display a map and search field. A user can enter their location by placing a pin on the map, searching for a named place or postcode, or (should they know it) directly entering their latitude and longitude. However entered, the location will be displayed in the input field and submitted in the format latitude,longitude, ie 50.413399,-4.0997.

As the map is provided by Google, your site will need access to the internet (meaning some internal intranets may run into problems).

Before using the location picker field you should register an account an obtain an API key from Google. This API key can be entered directly into a property in the location picker field or held in the subsite configuration and automatically made available to all of the forms using the field.

Custom Functions

Custom functions can be called from the handlers of other fields using .invokeCustomFieldFn.

  • search(value) - perform a search using the supplied value
  • hideMap() - hide the map
  • showMap() - show the map

Properties

LabelDescriptionType Name
LabelThe label for this fieldLABEL
Show LabelWhether to show the label for this field or not. This property adds/removes a class on the field's label element. The styling itself is controlled by the site's stylesheetSHOWLABEL
HintAdditional information displayed alongside the field to assist the user in completing it. The value of another field can be used by adding the field's name between # characters. See Common Field Properties for more informationHINT
Show LocationWhether the location input field should be visible or notSHOWLOCATION
RequiredWhether or not the field is required to have a value to pass validationREQUIRED
Default LocationThe default location that the map should be centred upon. Set the latitude and longitude, separated by a comma. For example 50.4233524,-4.0965925DEFAULTLOC
Auto LocateThe field will attempt to set its value as the position, in lat-long, returned by the geo-location feature of the device used to view the form. This will prompt the user to allow their location to be shared with the siteAUTODEFAULT
Error MessageThe error message that will be displayed if this field fails its validationERRMSG
Error Message FunctionA function that can be used to override the default error message. You can return a different message for each error type. The message can include the value of another field can be used by adding the field's name between # characters. See Error Message Functions for more information.

This field has the following error types:
 
  • REQUIRED - the field is required but has been left blank
  • VALIDATIONFUNCTION - the result of a custom validation function failing (validation function can also return custom error types)
ERRMSGFUNC
Location WidthThe display width of the input field. The value matches a CSS class, which actually sets the widthWIDTH
SearchableWhether this field's value should be indexed by the search (the object collection if using the database save action and/or workflow process collection if starting a workflow process).

This property is ignored if an External Type is specified for the form. In this case, the ability to search is determined by the searchable property of the type itself
SEARCHABLE
Show ButtonThe text to display on the show map buttonSHOWMAPLABEL
Hide ButtonThe text to display on the hide map buttonHIDEMAPLABEL
Search ButtonThe text to display on the search button. Leave this blank to omit the search input field and the search buttonSEARCHLABEL
Reset ButtonThe text to display on the reset button. Leave this blank to omit the reset button. The reset button resets the entire field to how it was when first loadedRESETLABEL
Clear ButtonThe text to display on the clear button. Leave this blank to omit the clear button. The clear button clears the search and location fields, but leaves the map focus where it currently isCLEARLABEL
Search WidthThe display width of the search field. The value matches a CSS class, which actually sets the widthSEARCHWIDTH
Search HintInitial search hint text to be displayed in the search input fieldSEARCHHINT
Map TypeThe initial type of Google map to display. the user can change this using controls provided by Google on the map. The following map types are supported:

ROADMAP (normal, default 2D map)
SATELLITE (photographic map)
HYBRID (photographic map + roads and city names)
TERRAIN (map with mountains, rivers, etc.)
MAPTYPE
Search PositionWhether the search panel is positioned above or below the map. The search panel includes the search input field and the search, reset and clear buttonsSEARCHPOSITION
Map HeightHeight of the map in pixelsMAPHEIGHT
Map WidthWidth of the map in pixelsMAPWIDTH
Zoom LevelA zoom level of 0 shows the whole Earth. Higher zoom levels focus the map more locallyDEFAULTZOOMLEVEL
Expand MapWhether the map is expanded or hidden when the field first loadsEXPANDMAP
Validation FunctionA JavaScript function that can be used to provide custom field validation whenever the field value changes or the form is submitted. This function will be executed client-side, provided JavaScript is enabled in the browser, and repeated server-sideVALFUNC
HandlersA JavaScript function that is executed client-side whenever the page loads, or the field value changes. This function is useful for modifying the values of other fields based on an entered valueHANDLERS
Read OnlyDisplay the field as read onlyREADONLY
Google Maps API KeyThe API key, supplied by Google and registered to your site/user/account that is needed to access Google Maps. If a map API key is set in your subsite configuration this field can be left blank. The key should give access to the "Maps JavaScript API" and "Geocoding API"APIKEY
Google Maps Client IDA Client ID key, supplied by Google and registered to your site/user/account that is needed to access Google Maps. If a map Client ID key is set in your subsite configuration this field can be left blank. Client ID is used in preference to an API key where both are providedCLIENTID
Additional Styling ModifierAn optional CSS modifier for the field. See Common Field Properties for an exampleADDITIONALSTYLINGMODIFIER
DocumentationAdd documentation to your field to help explain any complex functionality to future users. You might include information on what the field does and how it relates to other fields on the form. Notes added here are only ever visible in the Forms Designer, they can be searched for, viewed and downloaded from the action panel. See Common Field Properties for an exampleDOCUMENTATION

Share this page

Facebook icon Twitter icon email icon

Print

print icon