Map API

You must Login before you can answer or comment on any questions.

Hi to the community!

I just start working with Titanium and i try to understand how the Maps API works, i have create a Map and i pass the 2 Annotations p1 and p2, in the Ti.Map.createView i set to true the userLocation, i pass the lon and lan vars to (p1 and mapview have the same latitude, longitude),

but the current position of the p1 is not the same with mapview,

how i can attach the p1 annotation to the mapview as the current position and also, how i can change the "Current Position" title in the mapview?

i'm using Ti SDK v1.8.2 on Mac

here is my code:

var lat = 37.30168900;
var lon = -122.03073100;
 
var p1 = Ti.Map.createAnnotation({
    latitude: lat,
    longitude: lon,
    title: "C.Norris",
    pincolor: Ti.Map.ANNOTATION_GREEN,
    animate: true
});
 
var p2 = Ti.Map.createAnnotation({
    latitude: 37.318844002395444,
    longitude: -122.01622009277344,
    title: "Samurai Master",
    pincolor: Ti.Map.ANNOTATION_RED,
    animate: true
});
 
var mapview = Ti.Map.createView({
    mapType: Ti.Map.STANDARD_TYPE,
    region: { latitude: lat, longitude: lon, latitudeDelta: 0.05, longitudeDelta: 0.05 },
    animate: true,
    regionFit: true,
    userLocation: true,
    annotations: [p1, p2]
});
 
win.add(mapview);
thanks a lot!

1 Answer

Accepted Answer

hi,

you can get your current position by geolocation method

see this demo

— answered 1 year ago by Mitul Bhalia
answer permalink
5 Comments
  • Thanks for your reference, but i already have the current position.

    lets say that is the lan and lon variables, i pass them to the map and also to the p1 annotation, can i pass the p1 to the mapview as the current position, or i have to remove the userLocation: true?

    — commented 1 year ago by Philip Artdev

  • if you set userLocation to true then map shows the blue dot and if you want p1 as current location then you should set that false.

    — commented 1 year ago by Mitul Bhalia

  • thanks Mitul, it's not possible to use userLocation:true and show an annotation or other info on it?, because the only info i get onclick in the blue dot, is a "Current Location" . It's not possible to change this title, or maybe... can i use the blue dot in an annotation?

    — commented 1 year ago by Philip Artdev

  • Show 2 more comments

Your Answer

Think you can help? Login to answer this question!