From cad3ef53f5cb1b47ff8922aef188a831b4110aab Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 17 Apr 2012 14:25:25 +0100 Subject: Work much better if reporting pin is clicked/dragged in/out of council boundary (CM17). --- web/js/map-OpenLayers.js | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 1574754c9..87876a723 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -7,6 +7,32 @@ function fixmystreet_update_pin(lonlat) { ); document.getElementById('fixmystreet.latitude').value = lonlat.lat || lonlat.y; document.getElementById('fixmystreet.longitude').value = lonlat.lon || lonlat.x; + + $.getJSON('/report/new/ajax', { + latitude: $('#fixmystreet\\.latitude').val(), + longitude: $('#fixmystreet\\.longitude').val() + }, function(data) { + if (data.error) { + if (!$('#side-form-error').length) { + $('
').insertAfter($('#side-form')); + } + $('#side-form-error').html('

Reporting a problem

' + data.error + '

').show(); + $('#side-form').hide(); + return; + } + $('#side-form, #site-logo').show(); + $('#councils_text').html(data.councils_text); + $('#form_category_row').html(data.category); + if ( data.extra_name_info ) { + // there might be a first name field on some cobrands + var lb = $('#form_first_name').prev() || $('#form_name').prev(); + lb.before(data.extra_name_info); + } + }); + + if (!$('#side-form-error').is(':visible')) { + $('#side-form, #site-logo').show(); + } } function fixmystreet_activate_drag() { @@ -419,7 +445,7 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { fixmystreet.markers.addFeatures( markers ); fixmystreet_activate_drag(); } - fixmystreet_update_pin(lonlat); + // check to see if markers are visible. We click the // link so that it updates the text in case they go // back @@ -427,23 +453,15 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { fixmystreet.state_pins_were_hidden = true; $('#hide_pins_link').click(); } + + // Store pin location in form fields, and check coverage of point + fixmystreet_update_pin(lonlat); + + // Already did this first time map was clicked, so no need to do it again. if (fixmystreet.page == 'new') { return; } - $.getJSON('/report/new/ajax', { - 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); - }); - $('#side-form, #site-logo').show(); fixmystreet.map.updateSize(); // might have done, and otherwise Firefox gets confused. /* For some reason on IOS5 if you use the jQuery show method it * doesn't display the JS validation error messages unless you do this -- cgit v1.2.3 From 98eb8e031e5082402fd88adf7d67bab910611973 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Tue, 8 May 2012 14:01:36 +0100 Subject: Allow display of areas on /around. --- web/js/map-OpenLayers.js | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 87876a723..544e6e850 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -69,22 +69,26 @@ function fms_markers_list(pins, transform) { } function fixmystreet_onload() { - if ( fixmystreet.area ) { - var area = new OpenLayers.Layer.Vector("KML", { - strategies: [ new OpenLayers.Strategy.Fixed() ], - protocol: new OpenLayers.Protocol.HTTP({ - url: "/mapit/area/" + fixmystreet.area + ".kml?simplify_tolerance=0.0001", - format: new OpenLayers.Format.KML() - }) - }); - fixmystreet.map.addLayer(area); - area.events.register('loadend', null, function(a,b,c) { - var bounds = area.getDataExtent(); - if (bounds) { - var center = bounds.getCenterLonLat(); - fixmystreet.map.setCenter(center, fixmystreet.map.getZoomForExtent(bounds), false, true); + if ( fixmystreet.area.length ) { + for (var i=0; i Date: Mon, 25 Jun 2012 16:53:57 +0100 Subject: delete overlooked conflict marker? --- web/js/map-OpenLayers.js | 1 - 1 file changed, 1 deletion(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index eca1fc074..4c96e771c 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -70,7 +70,6 @@ function fms_markers_list(pins, transform) { } function fixmystreet_onload() { -<<<<<<< HEAD if ( fixmystreet.area.length ) { for (var i=0; i