PDA

View Full Version : Problem accessing Ext.util.GeoLocation geolocation coordinates



bweiler
22 Apr 2011, 4:17 PM
I'm running into a strange problem accessing the Ext.util.GeoLocation (http://hwl2y21/dev/iphone/proj/voter/Sencha/touch/docs/source/GeoLocation.html#cls-Ext.util.GeoLocation) coordinates. The latitude and longitude are undefined and the coordinates appear to be nested indefinitely.

Has anyone run into this and found a workaround?

Thanks




MyApp.views.MapView = Ext.extend(Ext.Panel, {

id: 'mapView',
initComponent: function() {
Ext.apply(this, {
layout: 'fit',
dockedItems: [this.getToolbar()],
items: [this.getMap()]
});
MyApp.views.MapView.superclass.initComponent.apply(this, arguments);
},
getMap: function() {
this.mapPanel = new Ext.Map({
itemId: 'mapPanel',
useCurrentLocation: true
});
return this.mapPanel;
},
getToolbar: function() {
...
}
}

Ext.reg('mapview', MyApp.views.MapView);



Ext.regController("mapController", {
showMap: function(list, record) {
this.mapView = this.render({
xtype: 'mapview'
});
this.mapPanel = this.mapView.getComponent('mapPanel');
console.log("mapPanel", this.mapPanel);
}
});


Expanded object from console.log("mapPanel", this.mapPanel);



mapPanel Object
additionalCls: Array (0)
cancelAutoSize: true
componentCls: "x-map"
componentLayout: Object
container: Object
el: Object
events: Object
geo: Object
autoLoad: false
coords: Object
autoLoad: false
coords: Object
autoLoad: false
coords: Object
autoLoad: false
coords: Object
autoLoad: false
coords: Object
autoLoad: false
coords: Object
autoLoad: false
coords: Object
autoLoad: false
coords: Object
autoLoad: false
coords: Object
autoLoad: false
coords: Object
autoLoad: false
coords: Object
autoLoad: false
coords: Object
autoLoad: false
coords: Object
...

Anth0
31 May 2011, 2:00 PM
I'm having the same issue.

I've found no solution yet... Please keep me posted if you solve this.

beetree
21 Aug 2011, 4:56 PM
I tried making GeoLocation to work, but ended up going with the HTML5 solution instead. Here is my code:



function fetchLocation(position) {
coords = position.coords;
alert(coords.latitude);
}


if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(fetchLocation);
} else {
console.log("No location available");
}