Index: branches/Maps0.8/includes/services/GoogleMaps3/GoogleMap3Functions.js |
— | — | @@ -1,44 +0,0 @@ |
2 | | - /** |
3 | | - * Javascript functions for Google Maps v3 functionality in Maps. |
4 | | - * |
5 | | - * @file GoogleMap3Functions.js |
6 | | - * @ingroup MapsGoogleMaps3 |
7 | | - * |
8 | | - * @author Jeroen De Dauw |
9 | | - */ |
10 | | - |
11 | | -/** |
12 | | - * Created a new Map object with the provided properties and markers. |
13 | | - */ |
14 | | -function initGMap3( name, options, markerData ) { |
15 | | - options.center = new google.maps.LatLng( options.lat, options.lon ); |
16 | | - |
17 | | - var map = new google.maps.Map( document.getElementById( name ), options ); |
18 | | - |
19 | | - // TODO: types - http://code.google.com/apis/maps/documentation/v3/reference.html#MapTypeRegistry |
20 | | - |
21 | | - for ( var i = markerData.length - 1; i >= 0; i-- ) { |
22 | | - getGMaps3Marker( map, markerData[i] ); |
23 | | - } |
24 | | -} |
25 | | - |
26 | | -function getGMaps3Marker( map, data ) { |
27 | | - var marker = new google.maps.Marker( { |
28 | | - position: new google.maps.LatLng( data.lat, data.lon ), |
29 | | - map: map, |
30 | | - title: data.title, |
31 | | - icon: data.icon |
32 | | - } ); |
33 | | - |
34 | | - var bothTxtAreSet = data.title.length > 0 && data.label.length > 0; |
35 | | - var popupText = bothTxtAreSet ? '<b>' + data.title + '</b><hr />' + data.label : data.title + data.label; |
36 | | - |
37 | | - var infowindow = new google.maps.InfoWindow( { content: popupText } ); |
38 | | - |
39 | | - google.maps.event.addListener( marker, "click", function() { |
40 | | - infowindow.close(); |
41 | | - infowindow.open( map, marker ); |
42 | | - } ); |
43 | | - |
44 | | - return marker; |
45 | | -} |
\ No newline at end of file |
Index: branches/Maps0.8/includes/services/OpenLayers/OpenLayerFunctions.js |
— | — | @@ -1,187 +0,0 @@ |
2 | | - /** |
3 | | - * Javascript functions for Open Layers functionality in Maps and its extensions. |
4 | | - * |
5 | | - * Note: This file is for backward compatibility with MediaWiki <=1.16. |
6 | | - * |
7 | | - * @file OpenLayerFunctions.js |
8 | | - * @ingroup MapsOpenLayers |
9 | | - * |
10 | | - * @author Jeroen De Dauw |
11 | | - */ |
12 | | - |
13 | | -/** |
14 | | - * Creates and initializes an OpenLayers map. |
15 | | - * The resulting map is returned by the function but no further handling is required in most cases. |
16 | | - */ |
17 | | -function initOpenLayer( mapName, lon, lat, zoom, mapTypes, controls, marker_data, langCode ){ |
18 | | - |
19 | | - OpenLayers.Lang.setCode( langCode ); |
20 | | - |
21 | | - var hasImageLayer = false; |
22 | | - for ( i = 0, n = mapTypes.length; i < n; i++ ) { |
23 | | - // Idieally this would check if the objecct is of type OpenLayers.layer.image |
24 | | - if ( mapTypes[i].options && mapTypes[i].options.isImage === true ) { |
25 | | - hasImageLayer = true; |
26 | | - break; |
27 | | - } |
28 | | - } |
29 | | - |
30 | | - // Create a new OpenLayers map with without any controls on it. |
31 | | - var mapOptions = { |
32 | | - controls: [] |
33 | | - }; |
34 | | - |
35 | | - if ( !hasImageLayer ) { |
36 | | - mapOptions.projection = new OpenLayers.Projection("EPSG:900913"); |
37 | | - mapOptions.displayProjection = new OpenLayers.Projection("EPSG:4326"); |
38 | | - mapOptions.units = "m"; |
39 | | - mapOptions.numZoomLevels = 18; |
40 | | - mapOptions.maxResolution = 156543.0339; |
41 | | - mapOptions.maxExtent = new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34); |
42 | | - } |
43 | | - |
44 | | - var mapElement = document.getElementById( mapName ); |
45 | | - |
46 | | - // Remove the loading map message. |
47 | | - mapElement.innerHTML = ''; |
48 | | - |
49 | | - var map = new OpenLayers.Map(mapName, mapOptions); |
50 | | - |
51 | | - // Add the controls. |
52 | | - for ( var i = controls.length - 1; i >= 0; i-- ) { |
53 | | - |
54 | | - // If a string is provided, find the correct name for the control, and use eval to create the object itself. |
55 | | - if ( typeof controls[i] == 'string' ) { |
56 | | - if ( controls[i].toLowerCase() == 'autopanzoom' ) { |
57 | | - if ( mapElement.offsetHeight > 140 ) controls[i] = mapElement.offsetHeight > 320 ? 'panzoombar' : 'panzoom'; |
58 | | - } |
59 | | - |
60 | | - control = getValidControlName( controls[i] ); |
61 | | - |
62 | | - if ( control ) { |
63 | | - eval(' map.addControl( new OpenLayers.Control.' + control + '() ); '); |
64 | | - } |
65 | | - } |
66 | | - else { |
67 | | - map.addControl(controls[i]); // If a control is provided, instead a string, just add it. |
68 | | - controls[i].activate(); // And activate it. |
69 | | - } |
70 | | - |
71 | | - } |
72 | | - |
73 | | - // Add the base layers. |
74 | | - for ( i = 0, n = mapTypes.length; i < n; i++ ) map.addLayer( mapTypes[i] ); |
75 | | - |
76 | | - // Layer to hold the markers. |
77 | | - var markerLayer = new OpenLayers.Layer.Markers( msgMarkers ); |
78 | | - markerLayer.id= 'markerLayer'; |
79 | | - map.addLayer( markerLayer ); |
80 | | - |
81 | | - var centerIsSet = lon != null && lat != null; |
82 | | - |
83 | | - var bounds = null; |
84 | | - |
85 | | - if ( marker_data.length > 1 && ( !centerIsSet || zoom == null ) ) { |
86 | | - bounds = new OpenLayers.Bounds(); |
87 | | - } |
88 | | - |
89 | | - for ( i = marker_data.length - 1; i >= 0; i-- ) { |
90 | | - marker_data[i].lonlat = new OpenLayers.LonLat( marker_data[i].lon, marker_data[i].lat ); |
91 | | - |
92 | | - if ( !hasImageLayer ) { |
93 | | - marker_data[i].lonlat.transform( new OpenLayers.Projection( "EPSG:4326" ), new OpenLayers.Projection( "EPSG:900913" ) ); |
94 | | - } |
95 | | - |
96 | | - if ( bounds != null ) bounds.extend( marker_data[i].lonlat ); // Extend the bounds when no center is set. |
97 | | - markerLayer.addMarker( getOLMarker( markerLayer, marker_data[i] ) ); // Create and add the marker. |
98 | | - } |
99 | | - |
100 | | - if ( bounds != null ) map.zoomToExtent( bounds ); // If a bounds object has been created, use it to set the zoom and center. |
101 | | - |
102 | | - if (centerIsSet) { // When the center is provided, set it. |
103 | | - var centre = new OpenLayers.LonLat(lon, lat); |
104 | | - |
105 | | - if ( !hasImageLayer ) { |
106 | | - centre.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")); |
107 | | - } |
108 | | - |
109 | | - map.setCenter(centre); |
110 | | - } |
111 | | - |
112 | | - if (zoom != null) map.zoomTo(zoom); // When the zoom is provided, set it. |
113 | | - |
114 | | - return map; |
115 | | -} |
116 | | - |
117 | | -/** |
118 | | - * Gets a valid control name (with excat lower and upper case letters), |
119 | | - * or returns false when the control is not allowed. |
120 | | - */ |
121 | | -function getValidControlName( control ) { |
122 | | - var OLControls = [ |
123 | | - 'ArgParser', 'Attribution', 'Button', 'DragFeature', 'DragPan', |
124 | | - 'DrawFeature', 'EditingToolbar', 'GetFeature', 'KeyboardDefaults', 'LayerSwitcher', |
125 | | - 'Measure', 'ModifyFeature', 'MouseDefaults', 'MousePosition', 'MouseToolbar', |
126 | | - 'Navigation', 'NavigationHistory', 'NavToolbar', 'OverviewMap', 'Pan', |
127 | | - 'Panel', 'PanPanel', 'PanZoom', 'PanZoomBar', 'Permalink', |
128 | | - 'Scale', 'ScaleLine', 'SelectFeature', 'Snapping', 'Split', |
129 | | - 'WMSGetFeatureInfo', 'ZoomBox', 'ZoomIn', 'ZoomOut', 'ZoomPanel', |
130 | | - 'ZoomToMaxExtent' |
131 | | - ]; |
132 | | - |
133 | | - for ( var i = OLControls.length - 1; i >= 0; i-- ) { |
134 | | - if ( control == OLControls[i].toLowerCase() ) { |
135 | | - return OLControls[i]; |
136 | | - } |
137 | | - } |
138 | | - |
139 | | - return false; |
140 | | -} |
141 | | - |
142 | | -function getOLMarker(markerLayer, markerData) { |
143 | | - var marker; |
144 | | - |
145 | | - if (markerData.icon != "") { |
146 | | - //var iconSize = new OpenLayers.Size(10,17); |
147 | | - //var iconOffset = new OpenLayers.Pixel(-(iconSize.w/2), -iconSize.h); |
148 | | - marker = new OpenLayers.Marker(markerData.lonlat, new OpenLayers.Icon(markerData.icon)); // , iconSize, iconOffset |
149 | | - } else { |
150 | | - marker = new OpenLayers.Marker(markerData.lonlat); |
151 | | - } |
152 | | - |
153 | | - if ( markerData.title.length + markerData.label.length > 0 ) { |
154 | | - |
155 | | - // This is the handler for the mousedown event on the marker, and displays the popup. |
156 | | - marker.events.register('mousedown', marker, |
157 | | - function(evt) { |
158 | | - var popup = new OpenLayers.Feature(markerLayer, markerData.lonlat).createPopup(true); |
159 | | - |
160 | | - if (markerData.title.length > 0 && markerData.label.length > 0) { // Add the title and label to the popup text. |
161 | | - popup.setContentHTML('<b>' + markerData.title + '</b><hr />' + markerData.label); |
162 | | - } |
163 | | - else { |
164 | | - popup.setContentHTML(markerData.title + markerData.label); |
165 | | - } |
166 | | - |
167 | | - popup.setOpacity(0.85); |
168 | | - markerLayer.map.addPopup(popup); |
169 | | - OpenLayers.Event.stop(evt); // Stop the event. |
170 | | - } |
171 | | - ); |
172 | | - |
173 | | - } |
174 | | - |
175 | | - return marker; |
176 | | -} |
177 | | - |
178 | | -function initOLSettings(minWidth, minHeight) { |
179 | | - OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3; |
180 | | - OpenLayers.Util.onImageLoadErrorColor = 'transparent'; |
181 | | - OpenLayers.Feature.prototype.popupClass = OpenLayers.Class( |
182 | | - OpenLayers.Popup.FramedCloud, |
183 | | - { |
184 | | - 'autoSize': true, |
185 | | - 'minSize': new OpenLayers.Size(minWidth, minHeight) |
186 | | - } |
187 | | - ); |
188 | | -} |
\ No newline at end of file |