Index: branches/SemanticMaps0.8/includes/services/OpenLayers/SM_OpenLayersForms.js |
— | — | @@ -1,101 +0,0 @@ |
2 | | - /** |
3 | | - * Javascript functions for OpenLayers functionality in Semantic Maps |
4 | | - * |
5 | | - * @file SM_OpenLayersFunctions.js |
6 | | - * @ingroup SMOpenLayers |
7 | | - * |
8 | | - * @author Jeroen De Dauw |
9 | | - */ |
10 | | - |
11 | | -/** |
12 | | - * This function holds specific functionality for the Open Layers form input of Semantic Maps. |
13 | | - */ |
14 | | -function makeFormInputOpenLayer( mapName, locationFieldName, lat, lon, zoom, marker_lat, marker_lon, layers, controls, height, langCode ) { |
15 | | - var markers = Array(); |
16 | | - |
17 | | - // Show a starting marker only if marker coordinates are provided. |
18 | | - if ( marker_lat != null && marker_lon != null ) { |
19 | | - markers.push( { "lat": marker_lat, "lon": marker_lon, "title": "", "label": "", "icon": "" } ); |
20 | | - } |
21 | | - |
22 | | - // Click event handler for updating the location of the marker |
23 | | - // TODO / FIXME: This will probably cause problems when used for multiple maps on one page. |
24 | | - OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { |
25 | | - defaultHandlerOptions: { |
26 | | - 'single': true, |
27 | | - 'double': false, |
28 | | - 'pixelTolerance': 0, |
29 | | - 'stopSingle': false, |
30 | | - 'stopDouble': false |
31 | | - }, |
32 | | - |
33 | | - initialize: function(options) { |
34 | | - this.handlerOptions = OpenLayers.Util.extend( |
35 | | - {}, this.defaultHandlerOptions |
36 | | - ); |
37 | | - OpenLayers.Control.prototype.initialize.apply( |
38 | | - this, arguments |
39 | | - ); |
40 | | - this.handler = new OpenLayers.Handler.Click( |
41 | | - this, { |
42 | | - 'click': this.trigger |
43 | | - }, this.handlerOptions |
44 | | - ); |
45 | | - }, |
46 | | - |
47 | | - trigger: function(e) { |
48 | | - var lonlat = map.getLonLatFromViewPortPx(e.xy); |
49 | | - |
50 | | - replaceMarker(mapName, lonlat); |
51 | | - |
52 | | - var proj = new OpenLayers.Projection("EPSG:4326"); |
53 | | - lonlat.transform(map.getProjectionObject(), proj); |
54 | | - |
55 | | - document.getElementById(locationFieldName).value = convertLatToDMS(lonlat.lat)+', '+convertLngToDMS(lonlat.lon); |
56 | | - } |
57 | | - |
58 | | - }); |
59 | | - |
60 | | - var clickHanler = new OpenLayers.Control.Click(); |
61 | | - controls.push(clickHanler); |
62 | | - |
63 | | - var map = initOpenLayer( mapName, lon, lat, zoom, layers, controls, markers, height, langCode ); |
64 | | - |
65 | | - // Make the map variable available for other functions |
66 | | - if (!window.OLMaps) window.OLMaps = new Object; |
67 | | - eval("window.OLMaps." + mapName + " = map;"); |
68 | | -} |
69 | | - |
70 | | -/** |
71 | | - * Remove all markers from an OL map (that's in window.OLMaps), and place a new one. |
72 | | - * |
73 | | - * @param mapName Name of the map as in OLMaps[mapName]. |
74 | | - * @param newLocation The location for the new marker. |
75 | | - */ |
76 | | -function replaceMarker(mapName, newLocation) { |
77 | | - var map = OLMaps[mapName]; |
78 | | - var markerLayer = map.getLayer('markerLayer'); |
79 | | - |
80 | | - removeMarkers(markerLayer); |
81 | | - markerLayer.addMarker(getOLMarker( |
82 | | - markerLayer, |
83 | | - { lonlat:newLocation, title: "", label:"", icon:"" }, |
84 | | - map.getProjectionObject()) |
85 | | - ); |
86 | | - |
87 | | - map.panTo(newLocation); |
88 | | -} |
89 | | - |
90 | | -/** |
91 | | - * Removes all markers from a marker layer. |
92 | | - * |
93 | | - * @param markerLayer The layer to remove all markers from. |
94 | | - * @return |
95 | | - */ |
96 | | -function removeMarkers(markerLayer) { |
97 | | - var markerCollection = markerLayer.markers; |
98 | | - |
99 | | - for (var i = 0; i < markerCollection.length; i++) { |
100 | | - markerLayer.removeMarker(markerCollection[i]); |
101 | | - } |
102 | | -} |
\ No newline at end of file |