r83899 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83898‎ | r83899 | r83900 >
Date:14:48, 14 March 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on openlayers form input
Modified paths:
  • /branches/SemanticMaps0.8/includes/services/OpenLayers/jquery.openlayersinput.js (modified) (history)

Diff [purge]

Index: branches/SemanticMaps0.8/includes/services/OpenLayers/jquery.openlayersinput.js
@@ -22,7 +22,13 @@
2323 var updateButton = $( '<button />' ).text( mediaWiki.msg( 'semanticmaps-updatemap' ) );
2424
2525 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+
2733 return false;
2834 } );
2935
@@ -130,9 +136,7 @@
131137 function( data ) {
132138 if ( data.totalResultsCount ) {
133139 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 );
137141 }
138142 else {
139143 // TODO: notify no result
@@ -145,10 +149,15 @@
146150 );
147151 }
148152
 153+ function projectAndShowLocation( location, title ) {
 154+ location.transform( new OpenLayers.Projection( "EPSG:4326" ), new OpenLayers.Projection( "EPSG:900913" ) );
 155+ showLocation( location, title );
 156+ }
 157+
149158 /**
150 - * @param location: OpenLayers.LonLat object
 159+ * @param {OpenLayers.LonLat} location
151160 */
152 - function showLocation( location, address ) {
 161+ function showLocation( location, title ) {
153162 var markerLayer = mapDiv.map.getLayer('markerLayer');
154163 var markerCollection = markerLayer.markers;
155164
@@ -159,13 +168,19 @@
160169 var normalProjectionLocation = new OpenLayers.LonLat( location.lon, location.lat );
161170 normalProjectionLocation.transform( new OpenLayers.Projection( "EPSG:900913" ), new OpenLayers.Projection( "EPSG:4326" ) );
162171
 172+ var text = coord.dms( normalProjectionLocation.lat, normalProjectionLocation.lon );
 173+
 174+ if ( title != '' ) {
 175+ text = '<b>' + title + '</b><hr />' + text;
 176+ }
 177+
163178 markerLayer.addMarker(
164179 mapDiv.getOLMarker(
165180 markerLayer,
166181 {
167182 lonlat: location,
168 - text: '<b>' + address + '</b><hr />' + coord.dms( normalProjectionLocation.lat, normalProjectionLocation.lon ),
169 - title: address,
 183+ text: text,
 184+ title: title,
170185 icon: options.icon
171186 }
172187 )

Follow-up revisions

RevisionCommit summaryAuthorDate
r83900follow up to r83899jeroendedauw14:48, 14 March 2011

Status & tagging log