So far in this chapter, we have looked at the Ext.util.GeoLocation
and Ext.util.Map
classes of Sencha Touch to see how to get the location and how to display a map. In this recipe, we will put these two pieces together, so that the location information from the GeoLocation
class can be used on the Map
class in rendering the information on the map. This can then be used, for example, to highlight the nearest restaurants on the map, based on the current location.
Make sure that you have set up your development environment by following the recipes outlined in Chapter 1.
Carry out the following steps:
Create and open a new file named
ch10_03.js
and paste the following code into it:Ext.setup({ onReady: function() { var geo = new Ext.util.GeoLocation({ autoUpdate: true, listeners: { locationupdate: function (geo) { var map = Ext.getCmp('google-map-id'); map.update(geo); ...