Index: branches/SemanticMaps0.8/includes/services/OpenLayers/jquery.openlayersinput.js |
— | — | @@ -22,7 +22,13 @@ |
23 | 23 | var updateButton = $( '<button />' ).text( mediaWiki.msg( 'semanticmaps-updatemap' ) ); |
24 | 24 | |
25 | 25 | updateButton.click( function() { |
26 | | - // TODO |
| 26 | + var locations = coord.split( $( '#' + mapDivId + '_values' ).attr( 'value' ) ); |
| 27 | + var location = coord.parse( locations[0] ); |
| 28 | + |
| 29 | + if ( location !== false ) { |
| 30 | + projectAndShowLocation( new OpenLayers.LonLat( location.lon, location.lat ), '' ); |
| 31 | + } |
| 32 | + |
27 | 33 | return false; |
28 | 34 | } ); |
29 | 35 | |
— | — | @@ -130,9 +136,7 @@ |
131 | 137 | function( data ) { |
132 | 138 | if ( data.totalResultsCount ) { |
133 | 139 | if ( data.totalResultsCount > 0 ) { |
134 | | - var location = new OpenLayers.LonLat( data.geonames[0].lng, data.geonames[0].lat ); |
135 | | - location.transform( new OpenLayers.Projection( "EPSG:4326" ), new OpenLayers.Projection( "EPSG:900913" ) ); |
136 | | - showLocation( location, address ); |
| 140 | + showLocation( new OpenLayers.LonLat( data.geonames[0].lng, data.geonames[0].lat ), address ); |
137 | 141 | } |
138 | 142 | else { |
139 | 143 | // TODO: notify no result |
— | — | @@ -145,10 +149,15 @@ |
146 | 150 | ); |
147 | 151 | } |
148 | 152 | |
| 153 | + function projectAndShowLocation( location, title ) { |
| 154 | + location.transform( new OpenLayers.Projection( "EPSG:4326" ), new OpenLayers.Projection( "EPSG:900913" ) ); |
| 155 | + showLocation( location, title ); |
| 156 | + } |
| 157 | + |
149 | 158 | /** |
150 | | - * @param location: OpenLayers.LonLat object |
| 159 | + * @param {OpenLayers.LonLat} location |
151 | 160 | */ |
152 | | - function showLocation( location, address ) { |
| 161 | + function showLocation( location, title ) { |
153 | 162 | var markerLayer = mapDiv.map.getLayer('markerLayer'); |
154 | 163 | var markerCollection = markerLayer.markers; |
155 | 164 | |
— | — | @@ -159,13 +168,19 @@ |
160 | 169 | var normalProjectionLocation = new OpenLayers.LonLat( location.lon, location.lat ); |
161 | 170 | normalProjectionLocation.transform( new OpenLayers.Projection( "EPSG:900913" ), new OpenLayers.Projection( "EPSG:4326" ) ); |
162 | 171 | |
| 172 | + var text = coord.dms( normalProjectionLocation.lat, normalProjectionLocation.lon ); |
| 173 | + |
| 174 | + if ( title != '' ) { |
| 175 | + text = '<b>' + title + '</b><hr />' + text; |
| 176 | + } |
| 177 | + |
163 | 178 | markerLayer.addMarker( |
164 | 179 | mapDiv.getOLMarker( |
165 | 180 | markerLayer, |
166 | 181 | { |
167 | 182 | lonlat: location, |
168 | | - text: '<b>' + address + '</b><hr />' + coord.dms( normalProjectionLocation.lat, normalProjectionLocation.lon ), |
169 | | - title: address, |
| 183 | + text: text, |
| 184 | + title: title, |
170 | 185 | icon: options.icon |
171 | 186 | } |
172 | 187 | ) |