diff options
Diffstat (limited to 'web/js')
-rw-r--r-- | web/js/fixmystreet.js | 7 | ||||
-rw-r--r-- | web/js/map-OpenLayers.js | 28 | ||||
-rw-r--r-- | web/js/map-OpenStreetMap.js | 4 | ||||
-rw-r--r-- | web/js/map-bing-ol.js | 7 | ||||
-rw-r--r-- | web/js/map-wmts-zurich.js | 46 |
5 files changed, 83 insertions, 9 deletions
diff --git a/web/js/fixmystreet.js b/web/js/fixmystreet.js index e25c2a571..838351e8b 100644 --- a/web/js/fixmystreet.js +++ b/web/js/fixmystreet.js @@ -52,7 +52,8 @@ $(function(){ var form_submitted = 0; var submitted = false; - $("form.validate").validate({ + $("form.validate").each(function(){ + $(this).validate({ rules: validation_rules, messages: translation_strings, onkeyup: false, @@ -85,6 +86,7 @@ $(function(){ submitted = false; }, invalidHandler: function(form, validator) { submitted = true; } + }); }); $('input[type=submit]').click( function(e) { form_submitted = 1; } ); @@ -142,7 +144,8 @@ $(function(){ if($('.mobile').length){ $link.append(' <img src="/cobrands/fixmystreet/images/spinner-black.gif" alt="" align="bottom">'); }else{ - $link.append(' <img src="/cobrands/fixmystreet/images/spinner-yellow.gif" alt="" align="bottom">'); + var spincolor = $('<span>').css("color","white").css("color") === $('#front-main').css("background-color")? 'white' : 'yellow'; + $link.append(' <img src="/cobrands/fixmystreet/images/spinner-' + spincolor + '.gif" alt="" align="bottom">'); } geo_position_js.getCurrentPosition(function(pos) { $link.find('img').remove(); diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 88dc6d69e..62e94ed29 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -411,14 +411,30 @@ OpenLayers.Control.PanZoomFMS = OpenLayers.Class(OpenLayers.Control.PanZoom, { /* Overriding Permalink so that it can pass the correct zoom to OSM */ OpenLayers.Control.PermalinkFMS = OpenLayers.Class(OpenLayers.Control.Permalink, { - updateLink: function() { + _updateLink: function(alter_zoom) { var separator = this.anchor ? '#' : '?'; var href = this.base; if (href.indexOf(separator) != -1) { href = href.substring( 0, href.indexOf(separator) ); } - href += separator + OpenLayers.Util.getParameterString(this.createParams(null, this.map.getZoom()+fixmystreet.zoomOffset)); + var center = this.map.getCenter(); + if ( center && fixmystreet.state_map && fixmystreet.state_map == 'full' ) { + // Translate the permalink co-ords so that 'centre' is accurate + var $content = $('.content'), mb = $('#map_box'), + q = ( $content.offset().left - mb.offset().left + $content.width() ) / 2; + if (q < 0) { q = 0; } + var p = this.map.getViewPortPxFromLonLat(center); + p.x += q; + p.y += 25; + center = this.map.getLonLatFromViewPortPx(p); + } + + var zoom = this.map.getZoom(); + if ( alter_zoom ) { + zoom += fixmystreet.zoomOffset; + } + href += separator + OpenLayers.Util.getParameterString(this.createParams(center, zoom)); // Could use mlat/mlon here as well if we are on a page with a marker if (this.anchor && !this.element) { window.location.href = href; @@ -426,6 +442,14 @@ OpenLayers.Control.PermalinkFMS = OpenLayers.Class(OpenLayers.Control.Permalink, else { this.element.href = href; } + }, + updateLink: function() { + this._updateLink(0); + } +}); +OpenLayers.Control.PermalinkFMSz = OpenLayers.Class(OpenLayers.Control.PermalinkFMS, { + updateLink: function() { + this._updateLink(1); } }); diff --git a/web/js/map-OpenStreetMap.js b/web/js/map-OpenStreetMap.js index 54bf95964..9b8916946 100644 --- a/web/js/map-OpenStreetMap.js +++ b/web/js/map-OpenStreetMap.js @@ -7,8 +7,8 @@ function set_map_config(perm) { new OpenLayers.Control.ArgParser(), //new OpenLayers.Control.LayerSwitcher(), new OpenLayers.Control.Navigation(), - new OpenLayers.Control.Permalink(permalink_id), - new OpenLayers.Control.PermalinkFMS('osm_link', 'http://www.openstreetmap.org/'), + new OpenLayers.Control.PermalinkFMS(permalink_id), + new OpenLayers.Control.PermalinkFMSz('osm_link', 'http://www.openstreetmap.org/'), new OpenLayers.Control.PanZoomFMS({id: 'fms_pan_zoom' }) ]; } diff --git a/web/js/map-bing-ol.js b/web/js/map-bing-ol.js index 6d86663f0..34ea255e8 100644 --- a/web/js/map-bing-ol.js +++ b/web/js/map-bing-ol.js @@ -16,9 +16,14 @@ function set_map_config(perm) { new OpenLayers.Control.Attribution(), new OpenLayers.Control.ArgParser(), fixmystreet.nav_control, - new OpenLayers.Control.Permalink(permalink_id), + new OpenLayers.Control.PermalinkFMS(permalink_id), new OpenLayers.Control.PanZoomFMS({id: 'fms_pan_zoom' }) ]; + /* Linking back to around from report page, keeping track of map moves */ + if ( fixmystreet.page == 'report' ) { + fixmystreet.controls.push( new OpenLayers.Control.PermalinkFMS('key-tool-problems-nearby', '/around') ); + } + if (fixmystreet.map_type) { tile_base = fixmystreet.map_type; } diff --git a/web/js/map-wmts-zurich.js b/web/js/map-wmts-zurich.js index 682c62f39..cfff686e6 100644 --- a/web/js/map-wmts-zurich.js +++ b/web/js/map-wmts-zurich.js @@ -2,6 +2,34 @@ * Maps for FMZ using Zurich council's WMTS tile server */ +function fixmystreet_zurich_admin_drag() { + var admin_drag = new OpenLayers.Control.DragFeature( fixmystreet.markers, { + onComplete: function(feature, e) { + var lonlat = feature.geometry.clone(); + lonlat.transform( + fixmystreet.map.getProjectionObject(), + new OpenLayers.Projection("EPSG:4326") + ); + if (window.confirm( 'Richtiger Ort?' ) ) { + // Store new co-ordinates + document.getElementById('fixmystreet.latitude').value = lonlat.y; + document.getElementById('fixmystreet.longitude').value = lonlat.x; + } else { + // Put it back + var lat = document.getElementById('fixmystreet.latitude').value; + var lon = document.getElementById('fixmystreet.longitude').value; + lonlat = new OpenLayers.LonLat(lon, lat).transform( + new OpenLayers.Projection("EPSG:4326"), + fixmystreet.map.getProjectionObject() + ); + fixmystreet.markers.features[0].move(lonlat); + } + } + } ); + fixmystreet.map.addControl( admin_drag ); + admin_drag.activate(); +} + $(function(){ $('#map_layer_toggle').toggle(function(){ $(this).text('Luftbild'); @@ -10,6 +38,15 @@ $(function(){ $(this).text('Stadtplan'); fixmystreet.map.setBaseLayer(fixmystreet.map.layers[0]); }); + + /* Admin dragging of pin */ + if (fixmystreet.page == 'admin') { + if ($.browser.msie) { + $(window).load(fixmystreet_zurich_admin_drag); + } else { + fixmystreet_zurich_admin_drag(); + } + } }); /* @@ -34,6 +71,11 @@ $(function(){ fixmystreet.controls.push( new OpenLayers.Control.PanZoomFMS({id: 'fms_pan_zoom' }) ); } + /* Linking back to around from report page, keeping track of map moves */ + if ( fixmystreet.page == 'report' ) { + fixmystreet.controls.push( new OpenLayers.Control.PermalinkFMS('key-tool-problems-nearby', '/around') ); + } + fixmystreet.map_type = OpenLayers.Layer.WMTS; // Set DPI - default is 72 @@ -51,7 +93,7 @@ $(function(){ layer: "Hybrid", matrixSet: "nativeTileMatrixSet", requestEncoding: "REST", - url: "http://www.wmts.stadt-zuerich.ch/Hybrid/MapServer/WMTS/tile/", + url: "/maps/Hybrid/", style: "default", matrixIds: [ //{ identifier: "0", matrixHeight: 2, matrixWidth: 2, scaleDenominator: 250000, supportedCRS: "urn:ogc:def:crs:EPSG::21781", tileHeight: 256, tileWidth: 256, topLeftCorner: { lat: 30814423, lon: -29386322 } }, @@ -70,7 +112,7 @@ $(function(){ layer_options, OpenLayers.Util.applyDefaults({ name: "Stadtplan", layer: "Stadtplan", - url: "http://www.wmts.stadt-zuerich.ch/Stadtplan/MapServer/WMTS/tile/" + url: "/maps/Stadtplan/" }, layer_options) ]; |