summaryrefslogtreecommitdiff
path: root/chimere/static
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-09-28 18:23:50 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-09-28 18:23:50 +0200
commita7fc9216d540ae3383cdbae1d26abe33d92f9a72 (patch)
tree3744453f8fafa7edadc0b989ef29f261535f62da /chimere/static
parent94a213cc95235f73b6d6f7fb6ff30ad4309b4ce6 (diff)
downloadChimère-a7fc9216d540ae3383cdbae1d26abe33d92f9a72.tar.bz2
Chimère-a7fc9216d540ae3383cdbae1d26abe33d92f9a72.zip
Native search: adapt template, views and javascript
Diffstat (limited to 'chimere/static')
-rw-r--r--chimere/static/chimere/js/jquery.chimere.js105
-rw-r--r--chimere/static/chimere/js/search.js3
2 files changed, 74 insertions, 34 deletions
diff --git a/chimere/static/chimere/js/jquery.chimere.js b/chimere/static/chimere/js/jquery.chimere.js
index 223425e..026027d 100644
--- a/chimere/static/chimere/js/jquery.chimere.js
+++ b/chimere/static/chimere/js/jquery.chimere.js
@@ -286,7 +286,7 @@ function transformCoordToLonLat(coord) {
};
var settings = {};
/*
- * Publics methods
+ * Public methods
*/
var methods = {
/*
@@ -602,7 +602,7 @@ function transformCoordToLonLat(coord) {
source: settings[map_id].sourceVectors
});
settings[map_id].map.addLayer(settings[map_id].layerVectors);
- if (settings[map_id].edition) methods.activateEdition(map_id);
+ if (settings[map_id].edition) methods._activateEdition(map_id);
// OL3-deprecated settings[map_id].layerVectors.setOpacity(0.8);
/* OL3-deprecated-routing
@@ -670,7 +670,8 @@ function transformCoordToLonLat(coord) {
if (!settings[map_id].edition){
methods.loadCategories(map_id, function(){
if (settings[map_id].permalink) {
- post_load_helper = methods._param_map_from_permalink();
+ post_load_helper =
+ methods._param_map_from_permalink(map_id);
}
methods.loadGeoObjects(map_id, post_load_helper);
});
@@ -855,7 +856,7 @@ function transformCoordToLonLat(coord) {
$("#permalink").attr('href', uri + "#" + settings[map_id].permalink);
return settings[map_id].permalink
},
- _param_map_from_permalink: function(){
+ _param_map_from_permalink: function(map_id){
var items = settings[map_id].permalink.split(';');
var view = settings[map_id].map.getView();
@@ -950,7 +951,7 @@ function transformCoordToLonLat(coord) {
var current_feature = items[4];
var post_load_helper = function(){
if (current_feature){
- methods.showPopup(current_feature);
+ methods._showPopup(map_id, current_feature);
}
settings[map_id].layerDbFeatures.dispatchEvent('change');
settings[map_id].clusterLayer.dispatchEvent('change');
@@ -1020,7 +1021,7 @@ function transformCoordToLonLat(coord) {
};
settings[map_id]._reload_on_move();
},
- deactivateEdition: function(map_id){
+ _deactivateEdition: function(map_id){
settings[map_id].edition = false;
if (typeof settings[map_id].features != 'undefined'){
settings[map_id].map.removeInteraction(settings[map_id].draw);
@@ -1028,7 +1029,15 @@ function transformCoordToLonLat(coord) {
settings[map_id].editionSource.clear();
}
},
- activateEdition: function(map_id, new_edition_type){
+ deactivateEdition: function(){
+ var map_id = methods.map_id(this);
+ if (!map_id){
+ alert("deactivateEdition - Public method only");
+ return;
+ }
+ methods._deactivateEdition(map_id);
+ },
+ _activateEdition: function(map_id, new_edition_type){
settings[map_id].edition = true;
if (new_edition_type) settings[map_id].edition_type = new_edition_type;
@@ -1098,6 +1107,14 @@ function transformCoordToLonLat(coord) {
});
settings[map_id].modify_activated = false;
},
+ activateEdition: function(new_edition_type){
+ var map_id = methods.map_id(this);
+ if (!map_id){
+ alert("activateEdition - Public method only");
+ return;
+ }
+ methods._activateEdition(map_id, new_edition_type);
+ },
enableClustering: function(map_id){
// Style clusters and hide items inside clusters
settings[map_id]._styleCache = {};
@@ -1432,7 +1449,7 @@ function transformCoordToLonLat(coord) {
zoomIn: function(){
var map_id = methods.map_id(this);
if (!map_id){
- alert("Public method only");
+ alert("zoomIn - Public method only");
return;
}
v = settings[map_id].map.getView();
@@ -1460,7 +1477,7 @@ function transformCoordToLonLat(coord) {
zoomOut: function(){
var map_id = methods.map_id(this);
if (!map_id){
- alert("Public method only");
+ alert("zoomOut - Public method only");
return;
}
v = settings[map_id].map.getView();
@@ -1540,20 +1557,28 @@ function transformCoordToLonLat(coord) {
}
},
*/
- loadMarker: function(object_id, open_popup) {
+ _loadMarker: function(map_id, object_id, open_popup) {
var uri = extra_url + "get-marker/" + object_id;
$.ajax({url: uri,
dataType: "json",
success: function (data) {
var c_feat = null;
for (idx in data){
- c_feat = methods.addMarker(map_id, data[idx]);
+ c_feat = methods._addMarker(map_id, data[idx]);
}
if (c_feat && open_popup != 'undefined' && open_popup)
methods.openPopup(map_id, c_feat);
}
});
},
+ loadMarker: function(object_id, open_popup) {
+ var map_id = methods.map_id(this);
+ if (!map_id){
+ alert("loadMarker - Public method only");
+ return;
+ }
+ methods._loadMarker(map_id, object_id, open_popup);
+ },
/*
* Load markers and route from DB
*/
@@ -1599,7 +1624,7 @@ function transformCoordToLonLat(coord) {
for (var i = 0; i < data.features.length; i++) {
var feature = data.features[i];
if (feature.geometry.type == 'Point'){
- var iconFeature = methods.addMarker(map_id, feature);
+ var iconFeature = methods._addMarker(map_id, feature);
} else if (feature.geometry.type == 'Polygon') {
methods.addPolygon(map_id, feature);
} else if (feature.geometry.type == 'MultiPolygon') {
@@ -1635,7 +1660,12 @@ function transformCoordToLonLat(coord) {
});
},
razMap: function() {
- methods.hidePopup();
+ var map_id = methods.map_id(this);
+ if (!map_id){
+ alert("razMap - Public method only");
+ return;
+ }
+ methods._hidePopup(map_id);
methods.uncheckCategories();
settings[map_id].dbFeatures.clear();
settings[map_id].vectors.clear();
@@ -1898,7 +1928,7 @@ function transformCoordToLonLat(coord) {
activateDraw: function (){
var map_id = methods.map_id(this);
if (!map_id){
- alert("Public method only");
+ alert("activateDraw - Public method only");
return;
}
settings[map_id].map.addInteraction(settings[map_id].draw);
@@ -1909,7 +1939,7 @@ function transformCoordToLonLat(coord) {
activateModify: function (){
var map_id = methods.map_id(this);
if (!map_id){
- alert("Public method only");
+ alert("activateModify - Public method only");
return;
}
settings[map_id].map.addInteraction(settings[map_id].modify);
@@ -1918,7 +1948,7 @@ function transformCoordToLonLat(coord) {
deactivateDraw: function (){
var map_id = methods.map_id(this);
if (!map_id){
- alert("Public method only");
+ alert("deactivateDraw - Public method only");
return;
}
if (settings[map_id].draw_activated){
@@ -1957,7 +1987,7 @@ function transformCoordToLonLat(coord) {
/*
* Put a marker on the map
*/
- addMarker: function (map_id, mark) {
+ _addMarker: function (map_id, mark) {
/*
* Default Feature configuration
* This can be overrided in on_marker_click, using settings[map_id].current_feature
@@ -2158,6 +2188,14 @@ function transformCoordToLonLat(coord) {
return feature;
*/
},
+ addMarker: function (mark) {
+ var map_id = methods.map_id(this);
+ if (!map_id){
+ alert("addMarker - Public method only");
+ return;
+ }
+ return methods._addMarker(map_id, mark);
+ },
//LIB iOS
connectWebViewJavascriptBridge: function(callback) {
@@ -2179,7 +2217,7 @@ function transformCoordToLonLat(coord) {
addJSON: function(json_url, title, projection, style){
var map_id = methods.map_id(this);
if (!map_id){
- alert("Public method only");
+ alert("addJSON - Public method only");
return;
}
@@ -2968,7 +3006,7 @@ function transformCoordToLonLat(coord) {
var map_id = methods.map_id(this);
if (!map_id){
- alert("Public method only");
+ alert("zoom - Public method only");
return;
}
@@ -3093,7 +3131,7 @@ function transformCoordToLonLat(coord) {
putEditMarker: function (latlon, zoom){
var map_id = methods.map_id(this);
if (!map_id){
- alert("Public method only");
+ alert("putEditMarker - Public method only");
return;
}
if (settings[map_id].features.getLength()) settings[map_id].features.pop();
@@ -3242,35 +3280,34 @@ function transformCoordToLonLat(coord) {
var bounds = settings[map_id].layerVectors.getDataExtent();
if (bounds) settings[map_id].map.zoomToExtent(bounds);
},
- showPopup: function (feature_pk) {
+ _showPopup: function (map_id, feature_pk){
var feats = settings[map_id].dbFeatures.getArray();
for (j in feats){
var c_marker = feats[j];
if (c_marker.getProperties()['key'] == feature_pk){
- //for (j in c_marker) console.log(j + ": "+ c_marker[j]);
- //c_marker.events.triggerEvent('click');
methods.openPopup(map_id, c_marker);
return true
}
}
// only manage marker for now
if (feature_pk.substring(0, 7) == "marker-"){
- var feat = methods.loadMarker(feature_pk.substring(7), true);
+ var feat = methods._loadMarker(map_id, feature_pk.substring(7),
+ true);
}
return false;
- //feature.markerClick();
- //OpenLayers.Popup.popupSelect.clickFeature(feature);
- /*
- settings[map_id].current_popup = feature.marker._popup();
- if (!settings[map_id].current_popup.visible()){
- settings[map_id].current_popup.show();
- methods.display_feature_detail(feature.pk);
- }*/
+ },
+ showPopup: function (feature_pk) {
+ var map_id = methods.map_id(this);
+ if (!map_id){
+ alert("showPopup - Public method only");
+ return;
+ }
+ return methods._showPopup(map_id, feature_pk);
},
hidePopup: function () {
var map_id = methods.map_id(this);
if (!map_id){
- alert("Public method only");
+ alert("hidePopup - Public method only");
return;
}
methods._hidePopup(map_id);
@@ -3293,7 +3330,7 @@ function transformCoordToLonLat(coord) {
refresh: function(){
var map_id = methods.map_id(this);
if (!map_id){
- alert("Public method only");
+ alert("refresh - Public method only");
return;
}
settings[map_id].map.updateSize();
diff --git a/chimere/static/chimere/js/search.js b/chimere/static/chimere/js/search.js
index 429056e..97bba43 100644
--- a/chimere/static/chimere/js/search.js
+++ b/chimere/static/chimere/js/search.js
@@ -16,6 +16,9 @@ function haystack_search(evt, page){
var value = $('#id_q').val().replace(/#/g , "%23");
var c_url = search_url + "?q=" + value;
+ if ($('#id_area').val()){
+ c_url += "&area=" + $('#id_area').val();
+ }
if (page){
c_url += '&page=' + page;
}