I want to create some simple navigation in sencha touch 2. I have questions about:
-
How to load Google maps with current location only once, when we start app
-
How two get the distance between two markers?
Here’s my Position.js (Map rendering view):
Ext.define('GS.view.Position', {
extend: 'Ext.Map',
xtype: 'map',
config: {
title: 'Position',
iconCls: 'time',
useCurrentLocation: false,
mapOptions: {
zoom: 19
},
listeners: {
maprender : function(comp, map){
new google.maps.Marker({
position: new google.maps.LatLng(this._geo.getLatitude(), this._geo.getLongitude()),
map: map
});
new google.maps.Marker({
position: new google.maps.LatLng(51.266064,15.562048),
map: map
});
}
}
}
});
Waiting for Help
Miłosz
The Sencha Touch map component looks like it’s merely a container for setting up a map – i.e. Sencha Touch does not provide further methods to do distance, or drop pins – these services are used through the Google Maps API.
To calculate a distance I believe you can use the distance matrix service API call. Using Chrome Dev or Firebug you can check out the js that the “calculate distance” button is calling to invoke the service.
To load your current location can’t you just use the config option “useCurrentLocation” when you create the map object?
Hope some of that helps