Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Problems with making a Map View and Current Location

I am trying to open a Map View with an alert that shows my current location - seems pretty simple but I just get a blank screen - here is my code - what am I doing wrong?

http://pastie.org/887721

— asked March 26th 2010 by Tim Haslam
  • current
  • iphone
  • location
  • map
0 Comments

3 Answers

  • If you are running on Android, you need to go get a key from Google.

    The Best documentation for this is still on codestrong - http://www.codestrong.com/timobile/howto/using-maps-on-android

    Greg

    — answered March 26th 2010 by Gregor Munro
    permalink
    0 Comments
  • You are actually not creating an annotation.

    var annotation = Titanium.Map.createAnnotation({
        latitude:37.390749,
        longitude:-122.081651,
        title:"Appcelerator Headquarters",
        subtitle:'Mountain View, CA',
        pincolor:Titanium.Map.ANNOTATION_RED,
        animate:true,
        leftButton: '../images/appcelerator_small.png',
        myid:1 // CUSTOM ATTRIBUTE THAT IS PASSED INTO EVENT OBJECTS
    });
    
    — answered March 26th 2010 by Glenn Tillemans
    permalink
    0 Comments
  • @ Glenn - That works! It brings up the map, however, I don't want it to default to Apple Headquarters. I have read that we can't get the actual current location until we put it on a device, but it seems like this code:

    latitude:37.390749,
    longitude:-122.081651,
    

    is forcing it to that location which I don't want…

    — answered March 29th 2010 by Tim Haslam
    permalink
    1 Comment
    • function getLocation()
      {
      Titanium.Geolocation.addEventListener('location',function(e)
      {
          if (e.error) {
              alert('Sorry, but Geolocation not available in your device');
              return;
          }
      
          var longitude = e.coords.longitude;
          var latitude = e.coords.latitude;
          var altitude = e.coords.altitude;
          var heading = e.coords.heading;
          var accuracy = e.coords.accuracy;
          var speed = e.coords.accuracy;
          var timestamp = e.coords.timestamp;
          var altitude = e.coords.altitudeAccuracy;
      
              lat = e.coords.longitude;
              lon = e.coords.latitude;
           alert('lat '+lat+'long '+lon);
      
      
           });
      
      }
      

      — commented May 30th 2014 by Ardon Hall
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.