r54943 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54942‎ | r54943 | r54944 >
Date:16:04, 13 August 2009
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.3.
Modified paths:
  • /trunk/extensions/Maps/OpenLayers/OpenLayerFunctions.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/OpenLayers/OpenLayerFunctions.js
@@ -24,9 +24,6 @@
2525 controls: []
2626 }
2727
28 -
29 -
30 -
3128 var map = new OpenLayers.Map(mapName, mapOptions);
3229
3330 // Add the controls
@@ -63,12 +60,19 @@
6461 }
6562
6663 for (i in marker_data) {
 64+ marker_data[i].lonlat.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
6765 if (bounds != null) bounds.extend(marker_data[i].lonlat); // Extend the bounds when no center is set
6866 markerLayer.addMarker(getOLMarker(markerLayer, marker_data[i], map.getProjectionObject())); // Create and add the marker
6967 }
7068
7169 if (bounds != null) map.zoomToExtent(bounds); // If a bounds object has been created, use it to set the zoom and center
72 - if (centerIsSet) map.setCenter(new OpenLayers.LonLat(lon, lat)); // When the center is provided, set it
 70+
 71+ if (centerIsSet) { // When the center is provided, set it
 72+ var centre = new OpenLayers.LonLat(lon, lat);
 73+ centre.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
 74+ map.setCenter(centre);
 75+ }
 76+
7377 if (zoom != null) map.zoomTo(zoom); // When the zoom is provided, set it
7478
7579 return map;
@@ -109,7 +113,10 @@
110114 var usedNor = false; var usedSat = false; var usedHyb = false; var usedPhy = false; // Google types
111115 var usedBingNor = false; var usedBingHyb = false; var usedBingSat = false; // Bing types
112116 var usedYahooNor = false; var usedYahooHyb = false; var usedYahooSat = false; // Yahoo types
113 - var usedOLWMS = false; var usedNasa = false; var usedOSM = false;
 117+ var usedOLWMS = false; // OL types
 118+ var usedOSMnik = false; var usedOSMcycle = false; var usedOSMarender = false; // OSM types
 119+ var usedNasa = false; // Others
 120+
114121 var isDefaultBaseLayer = false;
115122
116123 // Add the base layers
@@ -128,22 +135,22 @@
129136 if (googleAPILoaded) {
130137 switch(mapTypes[i]) {
131138 case 'google-normal' :
132 - if (!usedNor){ newLayer = new OpenLayers.Layer.Google( 'Google Streets' /*, {sphericalMercator:true} */ ); usedNor = true; }
 139+ if (!usedNor){ newLayer = new OpenLayers.Layer.Google( 'Google Streets', {'sphericalMercator':true} ); usedNor = true; }
133140 break;
134141 case 'google-satellite' :
135 - if (!usedSat){ newLayer = new OpenLayers.Layer.Google( 'Google Satellite' , {type: G_SATELLITE_MAP /*, sphericalMercator:true */}); usedSat = true; }
 142+ if (!usedSat){ newLayer = new OpenLayers.Layer.Google( 'Google Satellite' , {type: G_SATELLITE_MAP , 'sphericalMercator':true}); usedSat = true; }
136143 break;
137144 case 'google-hybrid' :
138 - if (!usedHyb){ newLayer = new OpenLayers.Layer.Google( 'Google Hybrid' , {type: G_HYBRID_MAP /*, sphericalMercator:true */}); usedHyb = true; }
 145+ if (!usedHyb){ newLayer = new OpenLayers.Layer.Google( 'Google Hybrid' , {type: G_HYBRID_MAP , 'sphericalMercator':true}); usedHyb = true; }
139146 break;
140147 case 'google-physical' :
141 - if (!usedPhy){ newLayer = new OpenLayers.Layer.Google( 'Google Physical' , {type: G_PHYSICAL_MAP /*, sphericalMercator:true */}); usedPhy = true; }
 148+ if (!usedPhy){ newLayer = new OpenLayers.Layer.Google( 'Google Physical' , {type: G_PHYSICAL_MAP , 'sphericalMercator':true}); usedPhy = true; }
142149 break;
143150 case 'google' :
144 - if (!usedNor){ map.addLayer(new OpenLayers.Layer.Google( 'Google Streets' /*, {sphericalMercator:true} */)); usedNor = true; }
145 - if (!usedSat){ map.addLayer(new OpenLayers.Layer.Google( 'Google Satellite' , {type: G_SATELLITE_MAP /*, sphericalMercator:true */})); usedSat = true; }
146 - if (!usedHyb){ map.addLayer(new OpenLayers.Layer.Google( 'Google Hybrid' , {type: G_HYBRID_MAP /*, sphericalMercator:true */})); usedHyb = true; }
147 - if (!usedPhy){ map.addLayer(new OpenLayers.Layer.Google( 'Google Physical' , {type: G_PHYSICAL_MAP /*, sphericalMercator:true */})); usedPhy = true; }
 151+ if (!usedNor){ map.addLayer(new OpenLayers.Layer.Google( 'Google Streets' , {'sphericalMercator':true})); usedNor = true; }
 152+ if (!usedSat){ map.addLayer(new OpenLayers.Layer.Google( 'Google Satellite' , {type: G_SATELLITE_MAP , 'sphericalMercator':true})); usedSat = true; }
 153+ if (!usedHyb){ map.addLayer(new OpenLayers.Layer.Google( 'Google Hybrid' , {type: G_HYBRID_MAP , 'sphericalMercator':true})); usedHyb = true; }
 154+ if (!usedPhy){ map.addLayer(new OpenLayers.Layer.Google( 'Google Physical' , {type: G_PHYSICAL_MAP , 'sphericalMercator':true})); usedPhy = true; }
148155 break;
149156 }
150157 }
@@ -152,58 +159,50 @@
153160 }
154161 break;
155162 case 'bing' : case 'virtual-earth' :
156 - if (!usedBingNor){ map.addLayer(new OpenLayers.Layer.VirtualEarth( 'Bing Streets' , {type: VEMapStyle.Shaded} )); usedBingNor = true; }
157 - if (!usedBingSat){ map.addLayer(new OpenLayers.Layer.VirtualEarth( 'Bing Satellite' , {type: VEMapStyle.Aerial} )); usedBingSat = true; }
158 - if (!usedBingHyb){ map.addLayer(new OpenLayers.Layer.VirtualEarth( 'Bing Hybrid' , {type: VEMapStyle.Hybrid} )); usedBingHyb = true; }
 163+ if (!usedBingNor){ map.addLayer(new OpenLayers.Layer.VirtualEarth( 'Bing Streets' , {type: VEMapStyle.Shaded, 'sphericalMercator':true} )); usedBingNor = true; }
 164+ if (!usedBingSat){ map.addLayer(new OpenLayers.Layer.VirtualEarth( 'Bing Satellite' , {type: VEMapStyle.Aerial, 'sphericalMercator':true} )); usedBingSat = true; }
 165+ if (!usedBingHyb){ map.addLayer(new OpenLayers.Layer.VirtualEarth( 'Bing Hybrid' , {type: VEMapStyle.Hybrid, 'sphericalMercator':true} )); usedBingHyb = true; }
159166 break;
160167 case 'bing-normal' :
161 - if (!usedBingNor){ newLayer = new OpenLayers.Layer.VirtualEarth( 'Bing Streets' , {type: VEMapStyle.Shaded} ); usedBingNor = true; }
 168+ if (!usedBingNor){ newLayer = new OpenLayers.Layer.VirtualEarth( 'Bing Streets' , {type: VEMapStyle.Shaded, 'sphericalMercator':true} ); usedBingNor = true; }
162169 case 'bing-satellite' :
163 - if (!usedBingSat){ newLayer = new OpenLayers.Layer.VirtualEarth( 'Bing Satellite' , {type: VEMapStyle.Aerial} ); usedBingSat = true; }
 170+ if (!usedBingSat){ newLayer = new OpenLayers.Layer.VirtualEarth( 'Bing Satellite' , {type: VEMapStyle.Aerial, 'sphericalMercator':true} ); usedBingSat = true; }
164171 case 'bing-hybrid' :
165 - if (!usedBingHyb){ newLayer = new OpenLayers.Layer.VirtualEarth( 'Bing Hybrid' , {type: VEMapStyle.Hybrid} ); usedBingHyb = true; }
 172+ if (!usedBingHyb){ newLayer = new OpenLayers.Layer.VirtualEarth( 'Bing Hybrid' , {type: VEMapStyle.Hybrid, 'sphericalMercator':true} ); usedBingHyb = true; }
166173 case 'yahoo' :
167 - if (!usedYahooNor){ map.addLayer(new OpenLayers.Layer.Yahoo( 'Yahoo Streets' )); usedYahooNor = true; }
168 - if (!usedYahooSat){ map.addLayer(new OpenLayers.Layer.Yahoo( 'Yahoo Satellite', {'type': YAHOO_MAP_SAT} )); usedYahooSat = true; }
169 - if (!usedYahooHyb){ map.addLayer(new OpenLayers.Layer.Yahoo( 'Yahoo Hybrid', {'type': YAHOO_MAP_HYB} )); usedYahooHyb = true; }
 174+ if (!usedYahooNor){ map.addLayer(new OpenLayers.Layer.Yahoo( 'Yahoo Streets' ), {'sphericalMercator':true}); usedYahooNor = true; }
 175+ if (!usedYahooSat){ map.addLayer(new OpenLayers.Layer.Yahoo( 'Yahoo Satellite', {'type': YAHOO_MAP_SAT, 'sphericalMercator':true} )); usedYahooSat = true; }
 176+ if (!usedYahooHyb){ map.addLayer(new OpenLayers.Layer.Yahoo( 'Yahoo Hybrid', {'type': YAHOO_MAP_HYB, 'sphericalMercator':true} )); usedYahooHyb = true; }
170177 break;
171178 case 'yahoo-normal' :
172 - if (!usedYahooNor){ newLayer = new OpenLayers.Layer.Yahoo( 'Yahoo Streets' ); usedYahooNor = true; }
 179+ if (!usedYahooNor){ newLayer = new OpenLayers.Layer.Yahoo( 'Yahoo Streets', {'sphericalMercator':true} ); usedYahooNor = true; }
173180 break;
174181 case 'yahoo-satellite' :
175 - if (!usedYahooSat){ newLayer = new OpenLayers.Layer.Yahoo( 'Yahoo Satellite', {'type': YAHOO_MAP_SAT} ); usedYahooSat = true; }
 182+ if (!usedYahooSat){ newLayer = new OpenLayers.Layer.Yahoo( 'Yahoo Satellite', {'type': YAHOO_MAP_SAT, 'sphericalMercator':true} ); usedYahooSat = true; }
176183 break;
177184 case 'yahoo-hybrid' :
178 - if (!usedYahooHyb){ newLayer = new OpenLayers.Layer.Yahoo( 'Yahoo Hybrid', {'type': YAHOO_MAP_HYB} ); usedYahooHyb = true; }
 185+ if (!usedYahooHyb){ newLayer = new OpenLayers.Layer.Yahoo( 'Yahoo Hybrid', {'type': YAHOO_MAP_HYB, 'sphericalMercator':true} ); usedYahooHyb = true; }
179186 break;
180187 case 'openlayers' : case 'open-layers' :
181 - if (!usedOLWMS){ newLayer = new OpenLayers.Layer.WMS( 'OpenLayers WMS', 'http://labs.metacarta.com/wms/vmap0', {layers: 'basic'} ); usedOLWMS = true; }
 188+ if (!usedOLWMS){ newLayer = new OpenLayers.Layer.WMS( 'OpenLayers WMS', 'http://labs.metacarta.com/wms/vmap0', {layers: 'basic', 'sphericalMercator':true} ); usedOLWMS = true; }
182189 break;
183190 case 'nasa' :
184 - if (!usedNasa){ newLayer = new OpenLayers.Layer.WMS("NASA Global Mosaic", "http://t1.hypercube.telascience.org/cgi-bin/landsat7", {layers: "landsat7" /*, sphericalMercator:true */} ); usedNasa = true; }
 191+ if (!usedNasa){ newLayer = new OpenLayers.Layer.WMS("NASA Global Mosaic", "http://t1.hypercube.telascience.org/cgi-bin/landsat7", {layers: "landsat7", 'sphericalMercator':true} ); usedNasa = true; }
185192 break;
186 - // FIXME: this will cause the OL API to mess itself up - other coordinate system?
187 -
188193 case 'osm' : case 'openstreetmap' :
189 - window.alert('osm');
190 - if (!usedOSM){ newLayer = new OpenLayers.Layer.TMS(
191 - "OpenStreetMap (Mapnik)",
192 - "http://tile.openstreetmap.org/",
193 - {
194 - type: 'png', getURL: osm_getTileURL,
195 - displayOutsideMaxExtent: true,
196 - attribution: '<a href="http://www.openstreetmap.org/">OpenStreetMap</a>'
197 - }
198 - );
199 - usedOSM = true; }
 194+ if (!usedOSMarender){ map.addLayer(new OpenLayers.Layer.OSM.Osmarender("OSM arender")); usedOSMarender = true; }
 195+ if (!usedOSMnik){ map.addLayer(new OpenLayers.Layer.OSM.Mapnik("OSM Mapnik"), {'sphericalMercator':true}); usedOSMnik = true; }
 196+ if (!usedOSMcycle){ map.addLayer(new OpenLayers.Layer.OSM.CycleMap("Cycle Map"), {'sphericalMercator':true}); usedOSMcycle = true; }
200197 break;
 198+ case 'osmarender' :
 199+ if (!usedOSMarender){ newLayer = new OpenLayers.Layer.OSM.Osmarender("OSM arender"); usedOSMarender = true; }
 200+ break;
201201 case 'osm-nik' : case 'osm-mapnik' :
202 - if (!usedOSM){ newLayer = new OpenLayers.Layer.OSM.Mapnik("OSM Mapnik"); usedOSM = true; }
 202+ if (!usedOSMnik){ newLayer = new OpenLayers.Layer.OSM.Mapnik("OSM Mapnik"); usedOSMnik = true; }
203203 break;
204204 case 'osm-cycle' : case 'osm-cyclemap' :
205 - if (!usedOSM){ newLayer = new OpenLayers.Layer.OSM.CycleMap("Cycle Map"); usedOSM = true; }
 205+ if (!usedOSMcycle){ newLayer = new OpenLayers.Layer.OSM.CycleMap("Cycle Map"); usedOSMcycle = true; }
206206 break;
207 -
208207 }
209208
210209 if (newLayer != null) {
@@ -255,7 +254,6 @@
256255
257256 function getOLMarkerData(lon, lat, title, label) {
258257 lonLat = new OpenLayers.LonLat(lon, lat)
259 - //lonLat.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
260258 return {
261259 lonlat: lonLat,
262260 title: title,
@@ -282,7 +280,7 @@
283281 }
284282
285283 // Click event handler for updating the location of the marker
286 - // TODO/FIXME: This will probably cause problems when used for multiple maps on one page.
 284+ // TODO / FIXME: This will probably cause problems when used for multiple maps on one page.
287285 OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
288286 defaultHandlerOptions: {
289287 'single': true,

Status & tagging log