PDA

View Full Version : Map is not showing my current location



mchopra1980
6 Feb 2012, 3:41 AM
Dear all,

I am try to create an application with a map showing my current location - the map appears but it is not showing my current location, please help

<code>

var map;JobDeals.views.jobslistToolBar3 = new Ext.Toolbar({id: 'jobslistToolbar3',title: 'Job Map',items: [{text: 'Back',ui: 'back',handler: function () {JobDeals.views.viewport.setActiveItem('viewjobslist',{ type: 'slide', direction: 'left'})}}]});map = new Ext.Map({title: 'Map',iconCls: 'maps',useCurrentLocation: true,mapOptions: {zoom: 110}});JobDeals.views.JobsMapList = Ext.extend(Ext.Panel,{id:'viewjobmaplist',fullscreen:true,layout:'fit',dockedItems: [JobDeals.views.jobslistToolBar3],items:map});Ext.reg('jobsmap',JobDeals.views.JobsMapList)
</code>

mitchellsimoens
6 Feb 2012, 8:33 AM
You shouldn't use <code> tags, it's [code].

Does it prompt you to allow it to get your location?

mchopra1980
6 Feb 2012, 2:33 PM
No popup comes up, I tested it in chrome + on my galaxy tab.

Sasha172
8 Feb 2012, 1:49 AM
Add this to your map after the your mapoptions :



geo:new Ext.util.GeoLocation({ autoUpdate:true,
maximumAge: 0,
timeout:2000,
listeners:{
locationupdate: function(geo) {
center = new google.maps.LatLng(geo.latitude, geo.longitude);
if (map.rendered)
map.update(center)
else
map.on('activate', map.onUpdate, map, {single: true, data: center});
},
locationerror: function ( geo,
bTimeout,
bPermissionDenied,
bLocationUnavailable,
message) {
if(bLocationUnavailable){
alert('Your Current Location is Unavailable on this device');
}
else if (bPermissionDenied){
alert('Location capabilities have been disabled on this device.');
}
}
}
})


Hope this helps :) Cheers

mchopra1980
11 Feb 2012, 11:50 AM
I tried and received the message "Your Current Location is Unavailable on this device". Tested in chrome and with my android tab. below the complete site code:




var map;JobDeals.views.jobslistToolBar3 = new Ext.Toolbar({id: 'jobslistToolbar3',title: 'Job Map',items: [{text: 'Back',ui: 'back',handler: function () {JobDeals.views.viewport.setActiveItem('viewjobslist',{ type: 'slide', direction: 'left'})}}]});map = new Ext.Map({title: 'Map',iconCls: 'maps',useCurrentLocation: true,mapOptions: {zoom: 12},geo:new Ext.util.GeoLocation({ autoUpdate:true,maximumAge: 0,timeout:2000,listeners:{locationupdate: function(geo) {center = new google.maps.LatLng(geo.latitude, geo.longitude);if (map.rendered)map.update(center);else
map.on('activate', map.onUpdate, map, {single: true, data: center});},locationerror: function ( geo,bTimeout, bPermissionDenied, bLocationUnavailable, message) {if(bLocationUnavailable){alert('Your Current Location is Unavailable on this device');}else if (bPermissionDenied){alert('Location capabilities have been disabled on this device.');} }}})});JobDeals.views.JobsMapList = Ext.extend(Ext.Panel,{id:'viewjobmaplist',fullscreen:true,layout:'fit',dockedItems: [JobDeals.views.jobslistToolBar3],items:map});Ext.reg('jobsmap',JobDeals.views.JobsMapList)

Sasha172
12 Feb 2012, 8:03 PM
If you're trying it on the browser on ur desktop it won't work. The code I gave you doesnt work with the IP address.

From the code you've pasted.... You really need to read what ppl post above especially when you ask for help. Add the code from my earlier post to ur Map Object after the mapOptions part.

Another way is inserting the currentLocation in the xtype itself. eg.


{
xtype : 'map',
useCurrentLocation : true,
id : 'mymap;
}

mchopra1980
14 Feb 2012, 7:59 AM
sorry I am a total newbie - i am not getting your point, did I inserted your code in the wrong place? I put it right after mapoptions. Why will it not work in the browser?

Thanks for your patience ;)

mchopra1980
14 Feb 2012, 1:45 PM
I tried it also through my pad but it is not working i still get Los Altos Hills