From 18466c1477b47c7d8abf186d78f4ba21df9c18ff Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 29 Jun 2011 16:33:05 +0100 Subject: On Your Reports page, zoom map out to cover markers shown. --- web/js/map-OpenLayers.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 83e535f1c..e4de17764 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -65,6 +65,9 @@ YAHOO.util.Event.onContentReady('map', function() { fixmystreet.markers.addMarker(marker); } fixmystreet.map.addLayer(fixmystreet.markers); + if ( fixmystreet.zoomToBounds ) { + fixmystreet.map.zoomToExtent( fixmystreet.markers.getDataExtent() ); + } }); -- cgit v1.2.3 From 81c55de7598ff15f56de6341727ed46f7f9eed18 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 29 Jun 2011 22:39:50 +0100 Subject: Move to Vector layer rather than Markers, to be able to use the Strategy/Protocol features. --- web/js/map-OpenLayers.js | 84 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 69 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 e4de17764..fb11b89fa 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -41,30 +41,55 @@ YAHOO.util.Event.onContentReady('map', function() { return false; }); - fixmystreet.markers = new OpenLayers.Layer.Markers("Markers"); + var pin_layer_options = { + styleMap: new OpenLayers.StyleMap({ + 'default': new OpenLayers.Style({ + externalGraphic: "/i/pin${type}.gif", + graphicWidth: 32, + graphicHeight: 59, + graphicOpacity: 1, + graphicXOffset: -1, + graphicYOffset: -59 + }) + }) + }; + if (fixmystreet.page == 'around') { + //pin_layer_options.strategies = [ new OpenLayers.Strategy.BBOX() ]; + //pin_layer_options.protocol = new OpenLayers.Protocol.HTTP({ + // url: '/rss', + // params: fixmystreet.all_pins ? { all_pins: 1 } : { }, + // format: OpenLayers.Format.GeoRSS + //}); + } + fixmystreet.markers = new OpenLayers.Layer.Vector("Pins", pin_layer_options); + var cols = { 'red':'R', 'green':'G', 'blue':'B', 'purple':'P' }; + var markers = []; for (var i=0; i Date: Thu, 30 Jun 2011 01:36:20 +0100 Subject: Strategy/Format for updating pins as map is panned. --- web/js/map-OpenLayers.js | 74 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 23 deletions(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index fb11b89fa..4a7d3b97e 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -45,6 +45,7 @@ YAHOO.util.Event.onContentReady('map', function() { styleMap: new OpenLayers.StyleMap({ 'default': new OpenLayers.Style({ externalGraphic: "/i/pin${type}.gif", + graphicTitle: "${title}", graphicWidth: 32, graphicHeight: 59, graphicOpacity: 1, @@ -54,30 +55,16 @@ YAHOO.util.Event.onContentReady('map', function() { }) }; if (fixmystreet.page == 'around') { - //pin_layer_options.strategies = [ new OpenLayers.Strategy.BBOX() ]; - //pin_layer_options.protocol = new OpenLayers.Protocol.HTTP({ - // url: '/rss', - // params: fixmystreet.all_pins ? { all_pins: 1 } : { }, - // format: OpenLayers.Format.GeoRSS - //}); + pin_layer_options.strategies = [ new OpenLayers.Strategy.BBOX() ]; + pin_layer_options.protocol = new OpenLayers.Protocol.HTTP({ + url: '/ajax', + params: fixmystreet.all_pins ? { all_pins: 1, map: 'FMS' } : { map: 'FMS' }, + format: new OpenLayers.Format.FixMyStreet() + }); } fixmystreet.markers = new OpenLayers.Layer.Vector("Pins", pin_layer_options); - var cols = { 'red':'R', 'green':'G', 'blue':'B', 'purple':'P' }; - var markers = []; - for (var i=0; i Date: Thu, 30 Jun 2011 10:45:49 +0100 Subject: Paginate Reports pages, and add a map. --- web/js/map-OpenLayers.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'web/js/map-OpenLayers.js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 4a7d3b97e..821bbafc3 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -41,6 +41,21 @@ YAHOO.util.Event.onContentReady('map', function() { return false; }); + 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", + format: new OpenLayers.Format.KML() + }) + }); + fixmystreet.map.addLayer(area); + area.events.register('loadend', null, function(a,b,c) { + var bounds = area.getDataExtent(); + if (bounds) { fixmystreet.map.zoomToExtent( bounds ); } + }); + } + var pin_layer_options = { styleMap: new OpenLayers.StyleMap({ 'default': new OpenLayers.Style({ @@ -78,7 +93,8 @@ YAHOO.util.Event.onContentReady('map', function() { fixmystreet.map.addLayer(fixmystreet.markers); if ( fixmystreet.zoomToBounds ) { - fixmystreet.map.zoomToExtent( fixmystreet.markers.getDataExtent() ); + var bounds = fixmystreet.markers.getDataExtent(); + if (bounds) { fixmystreet.map.zoomToExtent( bounds ); } } }); -- cgit v1.2.3