+ });
+
+ map.addControl(new MapPositionControl());
+
+
+
+
+
+ function update_viewbox_field() {
+ // hidden HTML field
+ $('input[name=viewbox]')
+ .val($('input#use_viewbox')
+ .prop('checked') ? map_viewbox_as_string() : '');
+ }
+
+ map.on('move', function () {
+ display_map_position();
+ update_viewbox_field();
+ });
+
+ map.on('mousemove', function (e) {
+ display_map_position(e.latlng);
+ });
+
+ map.on('click', function (e) {
+ last_click_latlng = e.latlng;
+ display_map_position();
+ });
+
+ map.on('load', function () {
+ display_map_position();
+ });
+
+ $('input#use_viewbox').on('change', function () {
+ update_viewbox_field();
+ });
+
+ function get_result_element(position) {
+ return $('.result').eq(position);
+ }
+ // function marker_for_result(result) {
+ // return L.marker([result.lat, result.lon], { riseOnHover: true, title: result.name });
+ // }
+ function circle_for_result(result) {
+ var cm_style = {
+ radius: 10,
+ weight: 2,
+ fillColor: '#ff7800',
+ color: 'blue',
+ opacity: 0.75,
+ clickable: !is_reverse_search
+ };
+ return L.circleMarker([result.lat, result.lon], cm_style);
+ }
+
+ var layerGroup = (new L.layerGroup()).addTo(map);
+
+ function highlight_result(position, bool_focus) {
+ var result = nominatim_results[position];
+ if (!result) { return; }
+ var result_el = get_result_element(position);
+
+ $('.result').removeClass('highlight');
+ result_el.addClass('highlight');
+
+ layerGroup.clearLayers();
+
+ if (result.lat) {
+ var circle = circle_for_result(result);
+ circle.on('click', function () {
+ highlight_result(position);
+ });
+ layerGroup.addLayer(circle);