Index: trunk/extensions/SemanticMaps/OpenStreetMap/SM_OSMFunctions.js |
— | — | @@ -15,12 +15,12 @@ |
16 | 16 | |
17 | 17 | // Show a starting marker only if marker coordinates are provided |
18 | 18 | if (mapParams.lat != null && mapParams.lon != null) { |
19 | | - mapParams.markers = [(getOSMMarkerData(mapParams.lon, mapParams.lat, '', ''))]; |
| 19 | + mapParams.markers = [(getOSMMarkerData(mapParams.lon, mapParams.lat, '', '', ''))]; |
20 | 20 | } |
21 | 21 | |
22 | 22 | // Click event handler for updating the location of the marker |
23 | 23 | // TODO / FIXME: This will probably cause problems when used for multiple maps on one page. |
24 | | - OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { |
| 24 | + OpenLayers.Control.ClickHandler = OpenLayers.Class(OpenLayers.Control, { |
25 | 25 | defaultHandlerOptions: { |
26 | 26 | 'single': true, |
27 | 27 | 'double': false, |
— | — | @@ -44,14 +44,21 @@ |
45 | 45 | }, |
46 | 46 | |
47 | 47 | trigger: function(e) { |
48 | | - replaceMarker(mapName, map.getLonLatFromViewPortPx(e.xy)); |
49 | | - document.getElementById(locationFieldName).value = convertLatToDMS(map.getLonLatFromViewPortPx(e.xy).lat)+', '+convertLngToDMS(map.getLonLatFromViewPortPx(e.xy).lon); |
| 48 | + var lonlat = this.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); |
50 | 56 | } |
51 | 57 | |
52 | 58 | }); |
53 | 59 | |
54 | | - var clickHanler = new OpenLayers.Control.Click(); |
55 | | - mapParams.initializedContols = [clickHanler]; |
| 60 | + var clickHanler = new OpenLayers.Control.ClickHandler(); |
| 61 | + mapParams.controls.push(clickHanler); |
| 62 | + mapParams.initializedContols = []; |
56 | 63 | |
57 | 64 | var map = new slippymap_map(mapName, mapParams); |
58 | 65 | |
— | — | @@ -67,11 +74,12 @@ |
68 | 75 | * @return |
69 | 76 | */ |
70 | 77 | function replaceMarker(mapName, newLocation) { |
71 | | - var map = OSMMaps[mapName]; |
| 78 | + var map = slippymaps[mapName]; |
| 79 | + |
72 | 80 | var markerLayer = map.getLayer('markerLayer'); |
73 | 81 | |
74 | 82 | removeOSMMarkers(markerLayer); |
75 | | - markerLayer.addMarker(getOSMMarker(markerLayer, getOSMMarkerData(newLocation.lon, newLocation.lat, '', ''), map.getProjectionObject())); |
| 83 | + markerLayer.addMarker(getOSMMarker(markerLayer, getOSMMarkerData(newLocation.lon, newLocation.lat, '', '', ''), map.getProjectionObject())); |
76 | 84 | |
77 | 85 | map.panTo(newLocation); |
78 | 86 | } |