r61443 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61442‎ | r61443 | r61444 >
Date:22:51, 23 January 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
OSM fix
Modified paths:
  • /trunk/extensions/Maps/OpenStreetMap/OSMFunctions.min.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/OpenStreetMap/OSMFunctions.min.js
@@ -1 +1,21 @@
2 -var slippymaps=new Array();var mapId=0;var layer=null;if(false){addOnloadHook(slippymap_init);}function slippymap_init(){for(keyName in slippymaps){slippymaps[keyName].init();}}function getValidControlName(control){var OLControls=['ArgParser','Attribution','Button','DragFeature','DragPan','DrawFeature','EditingToolbar','GetFeature','KeyboardDefaults','LayerSwitcher','Measure','ModifyFeature','MouseDefaults','MousePosition','MouseToolbar','Navigation','NavigationHistory','NavToolbar','OverviewMap','Pan','Panel','PanPanel','PanZoom','PanZoomBar','Permalink','Scale','ScaleLine','SelectFeature','Snapping','Split','WMSGetFeatureInfo','ZoomBox','ZoomIn','ZoomOut','ZoomPanel','ZoomToMaxExtent'];for(i in OLControls){if(control==OLControls[i].toLowerCase()){return OLControls[i];}}return false;}function slippymap_map(mapId,mapParams){var self=this;this.mapId=mapId;for(key in mapParams)this[key]=mapParams[key];this.mapOptions={controls:[]};for(i in this.controls){if(this.controls[i].toLowerCase()=='autopanzoom'){if(this.height>140)this.controls[i]=this.height>320?'panzoombar':'panzoom';}control=getValidControlName(this.controls[i]);if(control){eval(' this.mapOptions.controls.push( new OpenLayers.Control.'+control+'() ); ');}}}slippymap_map.prototype.init=function(){var previewImage=document.getElementById(this.mapId+'-preview');if(previewImage)previewImage.style.display='none';this.map=this.osm_create(this.mapId,this.lon,this.lat,this.zoom,this.initializedContols);var centerIsSet=this.lon!=null&&this.lat!=null;var bounds=null;if(this.markers.length>0){var markerLayer=new OpenLayers.Layer.Markers('Markers');markerLayer.id='markerLayer';this.map.addLayer(markerLayer);if(this.markers.length>1&&(!centerIsSet||this.zoom==null)){bounds=new OpenLayers.Bounds();}for(i in this.markers){this.markers[i].lonlat.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));if(bounds!=null)bounds.extend(this.markers[i].lonlat);markerLayer.addMarker(getOSMMarker(markerLayer,this.markers[i],this.map.getProjectionObject()));}}if(bounds!=null)map.zoomToExtent(bounds);if(centerIsSet){var centre=new OpenLayers.LonLat(this.lon,this.lat);centre.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));this.map.setCenter(centre);}if(this.zoom!=null)this.map.zoomTo(this.zoom);}slippymap_map.prototype.osm_create=function(mapId,lon,lat,zoom,initializedContols){var osmLayer;var map=new OpenLayers.Map(mapId,this.mapOptions);if(initializedContols){for(i in initializedContols){map.addControl(initializedContols[i]);initializedContols[i].activate();}}if(this.layer=='osm-like'){osmLayer=new OpenLayers.Layer.OSM("OpenStreetMap",'http://cassini.toolserver.org/tiles/osm-like/'+this.locale+'/${z}/${x}/${y}.png');}map.addLayers([osmLayer]);map.setCenter(new OpenLayers.LonLat(lon,lat).transform(new OpenLayers.Projection('EPSG:4326'),map.getProjectionObject()),zoom);return map;}function getOSMMarkerData(lon,lat,title,label,icon){lonLat=new OpenLayers.LonLat(lon,lat);return{lonlat:lonLat,title:title,label:label,icon:icon};}function getOSMMarker(markerLayer,markerData,projectionObject){var marker;if(markerData.icon!=''){marker=new OpenLayers.Marker(markerData.lonlat,new OpenLayers.Icon(markerData.icon));}else{marker=new OpenLayers.Marker(markerData.lonlat);}if(markerData.title.length+markerData.label.length>0){marker.events.register('mousedown',marker,function(evt){var popup=new OpenLayers.Feature(markerLayer,markerData.lonlat).createPopup(true);if(markerData.title.length>0&&markerData.label.length>0){popup.setContentHTML('<b>'+markerData.title+"</b><hr />"+markerData.label);}else{popup.setContentHTML(markerData.title+markerData.label);}popup.setOpacity(0.85);markerLayer.map.addPopup(popup);OpenLayers.Event.stop(evt);});}return marker;}
\ No newline at end of file
 2+var slippymaps=new Array();var mapId=0;var layer=null;if(false){addOnloadHook(slippymap_init);}
 3+function slippymap_init(){for(keyName in slippymaps){slippymaps[keyName].init();}}
 4+function getValidControlName(control){var OLControls=['ArgParser','Attribution','Button','DragFeature','DragPan','DrawFeature','EditingToolbar','GetFeature','KeyboardDefaults','LayerSwitcher','Measure','ModifyFeature','MouseDefaults','MousePosition','MouseToolbar','Navigation','NavigationHistory','NavToolbar','OverviewMap','Pan','Panel','PanPanel','PanZoom','PanZoomBar','Permalink','Scale','ScaleLine','SelectFeature','Snapping','Split','WMSGetFeatureInfo','ZoomBox','ZoomIn','ZoomOut','ZoomPanel','ZoomToMaxExtent'];for(i in OLControls){if(control==OLControls[i].toLowerCase()){return OLControls[i];}}
 5+return false;}
 6+function slippymap_map(mapId,mapParams){var self=this;this.mapId=mapId;for(key in mapParams)
 7+this[key]=mapParams[key];this.mapOptions={controls:[]};for(i in this.controls){if(this.controls[i].toLowerCase()=='autopanzoom'){if(this.height>140)this.controls[i]=this.height>320?'panzoombar':'panzoom';}
 8+control=getValidControlName(this.controls[i]);if(control){eval(' this.mapOptions.controls.push( new OpenLayers.Control.'+control+'() ); ');}}}
 9+slippymap_map.prototype.init=function(){var previewImage=document.getElementById(this.mapId+'-preview');if(previewImage)
 10+previewImage.style.display='none';this.map=this.osm_create(this.mapId,this.lon,this.lat,this.zoom,this.initializedContols);var centerIsSet=this.lon!=null&&this.lat!=null;var bounds=null;if(this.markers.length>0){var markerLayer=new OpenLayers.Layer.Markers('Markers');markerLayer.id='markerLayer';this.map.addLayer(markerLayer);if(this.markers.length>1&&(!centerIsSet||this.zoom==null)){bounds=new OpenLayers.Bounds();}
 11+for(i in this.markers){this.markers[i].lonlat.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));if(bounds!=null)bounds.extend(this.markers[i].lonlat);markerLayer.addMarker(getOSMMarker(markerLayer,this.markers[i],this.map.getProjectionObject()));}}
 12+if(bounds!=null)map.zoomToExtent(bounds);if(centerIsSet){var centre=new OpenLayers.LonLat(this.lon,this.lat);centre.transform(new OpenLayers.Projection("EPSG:4326"),new OpenLayers.Projection("EPSG:900913"));this.map.setCenter(centre);}
 13+if(this.zoom!=null)this.map.zoomTo(this.zoom);}
 14+slippymap_map.prototype.osm_create=function(mapId,lon,lat,zoom,initializedContols){var osmLayer;var map=new OpenLayers.Map(mapId,this.mapOptions);if(initializedContols){for(i in initializedContols){map.addControl(initializedContols[i]);initializedContols[i].activate();}}
 15+if(this.layer=='osm-like'){osmLayer=new OpenLayers.Layer.OSM("OpenStreetMap",'http://cassini.toolserver.org/tiles/osm-like/'+this.locale+'/${z}/${x}/${y}.png');}
 16+map.addLayers([osmLayer]);map.setCenter(new OpenLayers.LonLat(lon,lat).transform(new OpenLayers.Projection('EPSG:4326'),map.getProjectionObject()),zoom);return map;}
 17+function getOSMMarkerData(lon,lat,title,label,icon){lonLat=new OpenLayers.LonLat(lon,lat);return{lonlat:lonLat,title:title,label:label,icon:icon};}
 18+function getOSMMarker(markerLayer,markerData,projectionObject){var marker;if(markerData.icon!=''){marker=new OpenLayers.Marker(markerData.lonlat,new OpenLayers.Icon(markerData.icon));}else{marker=new OpenLayers.Marker(markerData.lonlat);}
 19+if(markerData.title.length+markerData.label.length>0){marker.events.register('mousedown',marker,function(evt){var popup=new OpenLayers.Feature(markerLayer,markerData.lonlat).createPopup(true);if(markerData.title.length>0&&markerData.label.length>0){popup.setContentHTML('<b>'+markerData.title+"</b><hr />"+markerData.label);}
 20+else{popup.setContentHTML(markerData.title+markerData.label);}
 21+popup.setOpacity(0.85);markerLayer.map.addPopup(popup);OpenLayers.Event.stop(evt);});}
 22+return marker;}
\ No newline at end of file

Status & tagging log