[OpenLayers-Commits] r11282 - sandbox/camptocamp/mobile/openlayers/examples

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Feb 23 04:33:57 EST 2011


Author: pgiraud
Date: 2011-02-23 01:33:57 -0800 (Wed, 23 Feb 2011)
New Revision: 11282

Modified:
   sandbox/camptocamp/mobile/openlayers/examples/mobile-jq.html
Log:
Set the map center when clicking on the search results

Modified: sandbox/camptocamp/mobile/openlayers/examples/mobile-jq.html
===================================================================
--- sandbox/camptocamp/mobile/openlayers/examples/mobile-jq.html	2011-02-23 09:32:36 UTC (rev 11281)
+++ sandbox/camptocamp/mobile/openlayers/examples/mobile-jq.html	2011-02-23 09:33:57 UTC (rev 11282)
@@ -101,15 +101,21 @@
                         searchUrl += '&name_startsWith=' + $('#query')[0].value;
                         $.getJSON(searchUrl, function(data) {
                             $.each(data.geonames, function() {
+                                var place = this;
                                 $('<li>')
                                     .hide()
                                     .append($('<h2 />', {
-                                        text: this.name
+                                        text: place.name
                                     }))
                                     .append($('<p />', {
-                                        html: '<b>' + this.countryName + '</b> ' + this.fcodeName
+                                        html: '<b>' + place.countryName + '</b> ' + place.fcodeName
                                     }))
                                     .appendTo('#search_results')
+                                    .click(function() {
+                                        $.mobile.changePage('mappage');
+                                        var lonlat = new OpenLayers.LonLat(place.lng, place.lat);
+                                        map.setCenter(lonlat.transform(gg, sm), 10);
+                                    })
                                     .show();
                             });
                             $('#search_results').listview('refresh');



More information about the Commits mailing list