diff options
author | Matthew Somerville <matthew@mysociety.org> | 2011-06-30 10:45:49 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2011-06-30 10:45:49 +0100 |
commit | fb78afe61194ea9b6fbec9596d69627e315ab97f (patch) | |
tree | e7c15dab1f918edfe6b57c33de02e95dea885fce /web/js/map-OpenLayers.js | |
parent | 6db910f24b1c25bb32369fafde79cf0da83abed0 (diff) |
Paginate Reports pages, and add a map.
Diffstat (limited to 'web/js/map-OpenLayers.js')
-rw-r--r-- | web/js/map-OpenLayers.js | 18 |
1 files changed, 17 insertions, 1 deletions
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 ); } } }); |