summaryrefslogtreecommitdiff
path: root/static/main_map.js
diff options
context:
space:
mode:
authoretienne <etienne@9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864>2009-01-16 11:30:31 +0000
committeretienne <etienne@9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864>2009-01-16 11:30:31 +0000
commit87da1eec81aa180943a5ee959a7c16951c39b624 (patch)
treefd07f110627453db14ab7c8776e73494a8aad941 /static/main_map.js
parent386c30ef568e7e5cfdc31654c83fc972c9094c15 (diff)
downloadChimère-87da1eec81aa180943a5ee959a7c16951c39b624.tar.bz2
Chimère-87da1eec81aa180943a5ee959a7c16951c39b624.zip
Add a permalink - CSS improvment - French translation
git-svn-id: http://www.peacefrogs.net/svn/chimere/trunk@16 9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864
Diffstat (limited to 'static/main_map.js')
-rw-r--r--static/main_map.js91
1 files changed, 85 insertions, 6 deletions
diff --git a/static/main_map.js b/static/main_map.js
index bd149a1..62a9f0d 100644
--- a/static/main_map.js
+++ b/static/main_map.js
@@ -31,6 +31,7 @@ function checkAll(item, ids){
}
var map;
+var permalink;
/* availaible map layers */
var layerMapnik = new OpenLayers.Layer.OSM.Mapnik('Classic');
@@ -76,9 +77,10 @@ function updateCheckedCategories(){
display_submited = false;
for (var i = 0; i < inputs.length; i++) {
input = inputs[i];
+ // 'category_'.length : 9
if (input.checked
- && input.name.substring('category_'.length, 0) == 'category_'){
- id = input.name.substring('category_'.length, input.name.length);
+ && input.name.substring(9, 0) == 'category_'){
+ id = input.name.substring(9, input.name.length);
if(checked_categories) checked_categories += '_';
checked_categories += id;
}
@@ -86,6 +88,7 @@ function updateCheckedCategories(){
display_submited = true;
}
}
+ permalink.updateLink();
}
/* load marker and route layer from a JSON feature string */
@@ -264,6 +267,49 @@ function setDetail(response){
}
}
+/* new permalink createParams method - update when facilities are given to
+personalize the permalink */
+function createParams(center, zoom, layers) {
+ center = center || this.map.getCenter();
+ var params = OpenLayers.Util.getParameters(this.base);
+ // If there's still no center, map is not initialized yet.
+ // Break out of this function, and simply return the params from the
+ // base link.
+ if (center) {
+ //zoom
+ params.zoom = zoom || this.map.getZoom();
+ //lon,lat
+ var lat = center.lat;
+ var lon = center.lon;
+ if (this.displayProjection) {
+ var mapPosition = OpenLayers.Projection.transform(
+ { x: lon, y: lat },
+ this.map.getProjectionObject(),
+ this.displayProjection );
+ lon = mapPosition.x;
+ lat = mapPosition.y;
+ }
+ params.lat = Math.round(lat*100000)/100000;
+ params.lon = Math.round(lon*100000)/100000;
+ //layers
+ layers = layers || this.map.layers;
+ params.layers = '';
+ for (var i=0, len=layers.length; i<len; i++) {
+ var layer = layers[i];
+
+ if (layer.isBaseLayer) {
+ params.layers += (layer == this.map.baseLayer) ? "B" : "0";
+ } else {
+ params.layers += (layer.getVisibility()) ? "T" : "F";
+ }
+ }
+ /* only piece of code added */
+ params.checked_categories = checked_categories;
+ params.display_submited = display_submited;
+ }
+ return params;
+}
+
/* main initialisation function */
function init(){
/* set the main map */
@@ -273,14 +319,47 @@ function init(){
new OpenLayers.Control.ScaleLine()],
maxResolution: 156543.0399,
units: 'm',
- projection: new OpenLayers.Projection('EPSG:4326')
+ projection: new OpenLayers.Projection('EPSG:4326'),
+ theme:null
});
/*projection: new OpenLayers.Projection('EPSG:900913'),
displayProjection: new OpenLayers.Projection('EPSG:4326')*/
+ permalink = new OpenLayers.Control.Permalink("permalink");
+ permalink.createParams = createParams;
+ map.addControl(permalink);
+ // update with the translated permalink label
+ if(permalink_label && permalink.div && permalink.div.childNodes.length > 0){
+ permalink.div.childNodes[0].textContent = permalink_label;
+ }
map.addLayers([layerMapnik, cyclemap]);
- /* zoom to the appropriate extent */
- if (!zoomToCurrentExtent(map)){
- map.setCenter(centerLonLat, 12);
+ /* if from a permalink */
+ if (p_zoom) {
+ var p_centerLonLat = new OpenLayers.LonLat(p_lon, p_lat);
+ map.setCenter(p_centerLonLat, p_zoom);
+ if (p_display_submited) {
+ document.getElementById('display_submited_check').checked = true;
+ }
+ if (p_checked_categories){
+ /* ckeck selected categories and uncheck others */
+ inputs = window.document.forms["frm_categories"];
+ for (var i = 0; i < inputs.length; i++) {
+ input = inputs[i];
+ if (input.name.substring(9, 0) == 'category_'){
+ id = input.name.substring(9, input.name.length);
+ input.checked = false;
+ for (var cc=0; cc < p_checked_categories.length; cc++){
+ if (p_checked_categories[cc] == id){
+ input.checked = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ /* if not zoom to the extent in cookies */
+ else if (!zoomToCurrentExtent(map)){
+ /* if no extent in cookies zoom to default */
+ map.setCenter(centerLonLat, 13);
}
loadGeoObjects();
}