Titanium Community Questions & Answer Archive

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

How to stop Titanium.Map.createView showing Current Location at Apple?

I'm trying to bring up a mapview control with just the US showing with no markers. I get just the US map okay, but it always shows a Current Location marker at Infinite Loop (which appears after a short time delay) no matter what I do. I've reduced my experimental code to the bare minimum:

    var mapview = Titanium.Map.createView({
        mapType: Titanium.Map.STANDARD_TYPE,
        region: {latitude: 0, longitude: 0, latitudeDelta:0.04, longitudeDelta:0.04},
        animate:true,
        regionFit:true
        //userLocation:true
        //annotations:[newMarker]
    });
    win.add(mapview);

How can I stop the Current Location marker from showing until I get my own geolocation information and set my own Annotation markers?

And another question: Is there any documentation about all the parameters for Titanium.Map.createView? And how to use them to accomplish different objectives? I'm reduced to guessing and experimenting with the KitchenSink code.

— asked March 18th 2010 by Bruce Martin
  • maps
  • mapview
0 Comments

2 Answers

  • Accepted Answer

    If you are running this in the simulator then you will always get the Apple HQ location. It is just how the simulator works.

    One thing you can do, if you want to have the map zoomed and focused on your location is to build the map view in the callback of getCurrentPosition.

    Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
    
    //
    //  SET DISTANCE FILTER.  THIS DICTATES HOW OFTEN AN EVENT FIRES BASED ON THE DISTANCE THE DEVICE MOVES
    //  THIS VALUE IS IN METERS
    //
    Titanium.Geolocation.distanceFilter = 10;
    
    //
    // GET CURRENT POSITION - THIS FIRES ONCE
    //
    Titanium.Geolocation.getCurrentPosition(function(e)
    {
        if (e.error)
        {
            alert('HFL cannot get your current location');
            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.speed;
        var timestamp = e.coords.timestamp;
        var altitudeAccuracy = e.coords.altitudeAccuracy;
    
        //
        //CREATE MAP VIEW
        //
        var mapview = Titanium.Map.createView({
            mapType: Titanium.Map.STANDARD_TYPE,
            region: {latitude: latitude, longitude: longitude, latitudeDelta:0.01, longitudeDelta:0.01},
            animate:true,
            regionFit:true,
            userLocation:true,
            annotations:[annotation]
        });
    
        win.add(mapview);
    
    
    });
    
    — answered March 18th 2010 by Rob Edgell
    permalink
    0 Comments
  • when i am running this code in my emulator it will display an error like : HFL cannot get your current location

    — answered October 18th 2012 by Vijay B
    permalink
    0 Comments
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.