aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/map-OpenLayers.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/js/map-OpenLayers.js')
-rw-r--r--web/js/map-OpenLayers.js74
1 files changed, 51 insertions, 23 deletions
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<fixmystreet.pins.length; i++) {
- var pin = fixmystreet.pins[i];
- var loc = new OpenLayers.Geometry.Point(pin[1], pin[0]);
- loc.transform(
- new OpenLayers.Projection("EPSG:4326"),
- fixmystreet.map.getProjectionObject()
- );
- var marker = new OpenLayers.Feature.Vector(loc, {
- type: cols[pin[2]],
- id: pin[3]
- });
- markers.push( marker );
- }
+ var markers = fms_markers_list( fixmystreet.pins, true );
fixmystreet.markers.addFeatures( markers );
if (fixmystreet.page == 'around') {
fixmystreet.markers.events.register( 'featureselected', fixmystreet.markers, function(evt) {
@@ -96,6 +83,29 @@ YAHOO.util.Event.onContentReady('map', function() {
});
+function fms_markers_list(pins, transform) {
+ var cols = { 'red':'R', 'green':'G', 'blue':'B', 'purple':'P' };
+ var markers = [];
+ for (var i=0; i<pins.length; i++) {
+ var pin = pins[i];
+ var loc = new OpenLayers.Geometry.Point(pin[1], pin[0]);
+ if (transform) {
+ // The Strategy does this for us, so don't do it in that case.
+ loc.transform(
+ new OpenLayers.Projection("EPSG:4326"),
+ fixmystreet.map.getProjectionObject()
+ );
+ }
+ var marker = new OpenLayers.Feature.Vector(loc, {
+ type: cols[pin[2]],
+ id: pin[3],
+ title: pin[4]
+ });
+ markers.push( marker );
+ }
+ return markers;
+}
+
YAHOO.util.Event.addListener('hide_pins_link', 'click', function(e) {
YAHOO.util.Event.preventDefault(e);
var showhide = [
@@ -125,12 +135,12 @@ YAHOO.util.Event.addListener('all_pins_link', 'click', function(e) {
for (var i=0; i<texts.length; i+=3) {
if (this.innerHTML == texts[i+1]) {
this.innerHTML = texts[i+2];
- fixmystreet.markers.protocol.options.params = { all_pins: 1 };
+ fixmystreet.markers.protocol.options.params = { all_pins: 1, map: 'FMS' };
fixmystreet.markers.refresh( { force: true } );
lang = texts[i];
} else if (this.innerHTML == texts[i+2]) {
this.innerHTML = texts[i+1];
- fixmystreet.markers.protocol.options.params = { };
+ fixmystreet.markers.protocol.options.params = { map: 'FMS' };
fixmystreet.markers.refresh( { force: true } );
lang = texts[i];
}
@@ -199,6 +209,24 @@ OpenLayers.Control.PermalinkFMS = OpenLayers.Class(OpenLayers.Control.Permalink,
}
});
+/* Pan data handler */
+OpenLayers.Format.FixMyStreet = OpenLayers.Class(OpenLayers.Format.JSON, {
+ read: function(json, filter) {
+ if (typeof json == 'string') {
+ obj = OpenLayers.Format.JSON.prototype.read.apply(this, [json, filter]);
+ } else {
+ obj = json;
+ }
+ if (typeof(obj.current) != 'undefined')
+ document.getElementById('current').innerHTML = obj.current;
+ if (typeof(obj.current_near) != 'undefined')
+ document.getElementById('current_near').innerHTML = obj.current_near;
+ var markers = fms_markers_list( obj.pins, false );
+ return markers;
+ },
+ CLASS_NAME: "OpenLayers.Format.FixMyStreet"
+});
+
/* Click handler */
OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
defaultHandlerOptions: {