From c56f704e998b418aa3f11d5e3b6b86d6c7ce40e6 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 9 Mar 2011 22:21:04 +0000 Subject: Fixes to other map types to work with lat/lon. Split OSM JavaScript into core OpenLayers bits and OSM config bit. --- web/js/map-OpenLayers.js | 181 +++++++++++++++++++++++++++++++++++++++++ web/js/map-OpenStreetMap.js | 191 +++----------------------------------------- web/js/map-bing-ol.js | 40 +++------- web/js/map-bing.js | 2 +- web/js/map-google.js | 2 +- web/js/map-streetview.js | 34 +++----- web/js/map-tilma-ol.js | 33 ++++---- 7 files changed, 228 insertions(+), 255 deletions(-) create mode 100644 web/js/map-OpenLayers.js (limited to 'web/js') diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js new file mode 100644 index 000000000..3b887c10d --- /dev/null +++ b/web/js/map-OpenLayers.js @@ -0,0 +1,181 @@ +YAHOO.util.Event.onContentReady('map', function() { + + fixmystreet.ZOOM_OFFSET = 14; + + var perm = new OpenLayers.Control.Permalink(); + set_map_config(perm); + + fixmystreet.map = new OpenLayers.Map("map", { + controls: fixmystreet.controls, + displayProjection: new OpenLayers.Projection("EPSG:4326") + }); + + fixmystreet.layer_options = OpenLayers.Util.extend({ + zoomOffset: fixmystreet.ZOOM_OFFSET, + numZoomLevels: 4 + }, fixmystreet.layer_options); + var layer = new fixmystreet.map_type("", fixmystreet.layer_options); + fixmystreet.map.addLayer(layer); + + if (!fixmystreet.map.getCenter()) { + var centre = new OpenLayers.LonLat( fixmystreet.longitude, fixmystreet.latitude ); + centre.transform( + new OpenLayers.Projection("EPSG:4326"), + fixmystreet.map.getProjectionObject() + ); + fixmystreet.map.setCenter(centre, 2); + } + + if (document.getElementById('mapForm')) { + var click = new OpenLayers.Control.Click(); + fixmystreet.map.addControl(click); + click.activate(); + } + + /* To let permalink not be caught by the Click layer, answer found + * at http://www.mail-archive.com/users@openlayers.org/msg12958.html + * Not sure why you can't use eventListeners or events.register... + */ + OpenLayers.Event.observe( perm.element, "click", function(e) { + OpenLayers.Event.stop(e); + location.href = OpenLayers.Event.element(e).href; + return false; + }); + + fixmystreet.markers = new OpenLayers.Layer.Markers("Markers"); + var cols = { 'red':'R', 'green':'G', 'blue':'B', 'purple':'P' }; + for (var i=0; i