The locate plugin deals with autocompletion of input fields used to recenter on a feature on the map. It is based on AJAX requests.
When a few characters have been typed in the dedicated input field, an AJAX request is processed on the database defined by its DSN. The first results beginning with these characters are displayed in a drop down list.
When a result is clicked, the map is recentered on it.
The JavaScript part of this plugin is based on the script.aculo.us Autocompleter.
The plugin needs obviously to be activated using the
client_conf/client.ini
loadPlugins
parameter. For instance:
loadPlugins = auth, exportPdf, views, locate
To enable the plugin, you also need to add required parts in the
cartoclient.tpl
template.
In the <head> element:
{if $locate_active|default:''}<link rel="stylesheet" type="text/css" href="{r type=css plugin=locate}locate.css{/r}" />{/if} ... {if $locate_active|default:''}<script type="text/javascript" src="{r type=js}prototype.js{/r}"></script>{/if}
And in the <body> of the document (for example in the navigation folder):
{if $locate_active|default:''} {$locate_form} {/if}
Tip
Warning: make sure that the recentering in enabled (recenterActive = true
in client_conf/location.ini
)! The hidden inputs id_recenter_layer
and id_recenter_ids
are needed so the recentering functionnality works correctly.
-
locate.#.id
(# = 0, 1, 2, ...): id of the layer in layers.ini to recenter on. -
locate.#.label
(# = 0, 1, 2, ...): label of the locate input; Note that if you use the same label as in the layers.ini translations will operate. -
locate.#.sql
(# = 0, 1, 2, ...): SQL statement for the AJAX request to the database. It must return two fields:- an identifier : the value of the
id_attribute_string
field of the layer, in order to be able to recenter on the feature, - a label : a name for the feature to recenter on.
- an identifier : the value of the