Current Location does not work with Mapmodule

Asked

Viewed 32 times

1

Using Appcelerator, starting a new project and I need to put my current location on the map, but I can’t place it. I can only put a fixed point. Follow my codes below:

/Resources/ui/controller/Geolocation.js:

var points = [];
Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;

Titanium.Geolocation.distanceFilter = 10;

Titanium.Geolocation.getCurrentPosition(function(e){
activityScreen.show();

if (e.error)
{
    alert('HFL cannot get your current location');
    activityScreen.hide();
    return;
}

win.longitude   = e.coords.longitude;
win.latitude    = e.coords.latitude;

win.latitude    = -23.4438148;
win.longitude   = -46.5335198;

if(typeof(vc) != "undefined")
{
    vc.latitude     = win.latitude; 
    vc.longitude    = win.longitude;

    mapview.region = {
        latitude:win.latitude, longitude: win.longitude,
        latitudeDelta:0.1, longitudeDelta:0.1
    };

}

activityScreen.hide();

});

/Resources/ui/view/iphone/map/maps.js:

Ti.include("/ui/controller/geolocation.js");
var MapModule = require('ti.map');


var vc = MapModule.createAnnotation({
 latitude: win.latitude,
 longitude: win.longitude,
 title: 'Você está aqui',
 subtitle: 'São Paulo, SP',
 pincolor: MapModule.ANNOTATION_GREEN,
 image:"/ui/images/zapsacmini.png",
});

var walmart = MapModule.createAnnotation({
 latitude: -23.474891,
 longitude: -46.526756,
 title: 'Loja',
 subtitle: 'Guarulhos, SP',
 pincolor: MapModule.ANNOTATION_RED,
 image:"/ui/images/loja.png",
}); 


var mapview = MapModule.createView({
top:0,
height: "80%",
mapType: MapModule.NORMAL_TYPE,
region: {latitude: win.latitude, longitude: win.longitude, latitudeDelta: 0.001, longitudeDelta: 0.001},
annotations: [vc,walmart],
animate:true,
});

mapview.visible = false;

win.add(mapview);

When I test my application, only the fixed point (Store) appears. Only mine doesn’t show up Current Location!

Remembering that I’ve already put the key Nslocationalwaysusagedescription and Nslocationwheninuseusagedescription in my tiapp.xml

someone knows what’s wrong with that or correct code?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.