From b0cab8cf018c6119a47f81ea2a3cf5672d05c8a0 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 15 Mar 2012 09:40:43 +0000 Subject: Only move pan zoom on around page on mobile. --- web/js/map-OpenLayers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 3d2d3259a..7522ae7d6 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -213,7 +213,7 @@ $(function(){ displayProjection: new OpenLayers.Projection("EPSG:4326") }); - if ($('html').hasClass('mobile')) { + if ($('html').hasClass('mobile') && fixmystreet.page == 'around') { $('#fms_pan_zoom').css({ top: '2.75em !important' }); } -- cgit v1.2.3 From 257d609b986b5f70282c68b75858cc5f2323a400 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 16 Mar 2012 13:38:53 +0000 Subject: Return an error if map clicked outside boundary, fixes #270. --- web/js/map-OpenLayers.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 7522ae7d6..272fd6c12 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -433,6 +433,11 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { latitude: $('#fixmystreet\\.latitude').val(), longitude: $('#fixmystreet\\.longitude').val() }, function(data) { + if (data.error) { + // XXX If they then click back and click somewhere in the area, this error will still show. + $('#side-form').html('

Reporting a problem

' + data.error + '

'); + return; + } $('#councils_text').html(data.councils_text); $('#form_category_row').html(data.category); }); -- cgit v1.2.3 From 27b02dfb4bcf2fc84c3ffd15edc35ec84a8338ac Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 26 Mar 2012 18:59:08 +0100 Subject: Adjust figures for when map might not be top left of page. --- web/js/map-OpenLayers.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 272fd6c12..aa2b2b2eb 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -236,7 +236,7 @@ $(function(){ if (fixmystreet.state_map && fixmystreet.state_map == 'full') { // TODO Work better with window resizing, this is pretty 'set up' only at present - var q = $(window).width() / 4; + var q = $('#map_box').width() / 4; // Need to try and fake the 'centre' being 75% from the left fixmystreet.map.pan(-q, -25, { animate: false }); fixmystreet.map.events.register("movestart", null, function(e){ @@ -459,7 +459,12 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { // If we clicked the map somewhere inconvenient var sidebar = $('#report-a-problem-sidebar'); if (sidebar.css('position') == 'absolute') { - var w = sidebar.width(), h = sidebar.height(), o = sidebar.offset(); + var w = sidebar.width(), h = sidebar.height(), + o = sidebar.offset(), + $map_box = $('#map_box'), bo = $map_box.offset(); + // e.xy is relative to top left of map, which might not be top left of page + e.xy.x += bo.left; + e.xy.y += bo.top; if (e.xy.y <= o.top || (e.xy.x >= o.left && e.xy.x <= o.left + w + 24 && e.xy.y >= o.top && e.xy.y <= o.top + h + 64)) { // top of the page, pin hidden by header; // or underneath where the new sidebar will appear @@ -468,7 +473,7 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { fixmystreet.map.getProjectionObject() ); var p = fixmystreet.map.getViewPortPxFromLonLat(lonlat); - p.x -= $(window).width() / 3; + p.x -= $map_box.width() / 3; lonlat = fixmystreet.map.getLonLatFromViewPortPx(p); fixmystreet.map.panTo(lonlat); } -- cgit v1.2.3 From 5700e9cdc070bd62c0c82ab35dec61a34955fbaf Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 29 Mar 2012 12:40:10 +0100 Subject: On map page, move overlay to left hand side of map (and adjust pans appropriately). --- web/js/map-OpenLayers.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index aa2b2b2eb..1574754c9 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -236,7 +236,8 @@ $(function(){ if (fixmystreet.state_map && fixmystreet.state_map == 'full') { // TODO Work better with window resizing, this is pretty 'set up' only at present - var q = $('#map_box').width() / 4; + var $content = $('.content'), + q = ( $content.offset().left + $content.width() ) / 2; // Need to try and fake the 'centre' being 75% from the left fixmystreet.map.pan(-q, -25, { animate: false }); fixmystreet.map.events.register("movestart", null, function(e){ @@ -473,7 +474,7 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { fixmystreet.map.getProjectionObject() ); var p = fixmystreet.map.getViewPortPxFromLonLat(lonlat); - p.x -= $map_box.width() / 3; + p.x -= ( o.left + w ) / 2; lonlat = fixmystreet.map.getLonLatFromViewPortPx(p); fixmystreet.map.panTo(lonlat); } -- cgit v1.2.3 From 2ecaa78941ccba06d25514c43944cedda1cc67dd Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 9 May 2012 23:00:30 +0100 Subject: Deactivate SelectFeature whilst pins are hidden, to fix #297. --- web/js/map-OpenLayers.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 1574754c9..7ddaae299 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -118,10 +118,10 @@ function fixmystreet_onload() { var markers = fms_markers_list( fixmystreet.pins, true ); fixmystreet.markers.addFeatures( markers ); if (fixmystreet.page == 'around' || fixmystreet.page == 'reports' || fixmystreet.page == 'my') { - var select = new OpenLayers.Control.SelectFeature( fixmystreet.markers ); + fixmystreet.select_feature = new OpenLayers.Control.SelectFeature( fixmystreet.markers ); var selectedFeature; function onPopupClose(evt) { - select.unselect(selectedFeature); + fixmystreet.select_feature.unselect(selectedFeature); OpenLayers.Event.stop(evt); } fixmystreet.markers.events.register( 'featureunselected', fixmystreet.markers, function(evt) { @@ -142,8 +142,8 @@ function fixmystreet_onload() { feature.popup = popup; fixmystreet.map.addPopup(popup); }); - fixmystreet.map.addControl( select ); - select.activate(); + fixmystreet.map.addControl( fixmystreet.select_feature ); + fixmystreet.select_feature.activate(); } else if (fixmystreet.page == 'new') { fixmystreet_activate_drag(); } @@ -164,9 +164,11 @@ function fixmystreet_onload() { for (var i=0; i Date: Wed, 23 May 2012 12:49:59 +0100 Subject: Don't want this to happen if zoom is actually 0. --- web/js/map-OpenLayers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 7ddaae299..d73e2bfc8 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -246,7 +246,7 @@ $(function(){ fixmystreet.map.moveStart = { zoom: this.getZoom(), center: this.getCenter() }; }); fixmystreet.map.events.register("zoomend", null, function(e){ - if ( fixmystreet.map.moveStart && !fixmystreet.map.moveStart.zoom ) { + if ( fixmystreet.map.moveStart && !fixmystreet.map.moveStart.zoom && fixmystreet.map.moveStart.zoom !== 0 ) { return true; // getZoom() on Firefox appears to return null at first? } if ( !fixmystreet.map.moveStart || !this.getCenter().equals(fixmystreet.map.moveStart.center) ) { -- cgit v1.2.3