Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2123] iPhone Map user location is covered by annotations with custom images

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2012-07-26T11:50:02.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsannotation, ios, iphone, map
ReporterJonathan Harlap
AssigneeNeeraj Gupta
Created2011-04-15T03:11:07.000+0000
Updated2012-07-26T22:15:42.000+0000

Description

If you create a map view with userLocation:true and add annotations with custom images, the annotation images cover the userLocation marker. The following example code illustrates the bug, assuming you have an annotation.jpg, a trivial example of which I attached.

Titanium.UI.setBackgroundColor('#000');

var win = Titanium.UI.createWindow({  
    title:'Map Bug',
    backgroundColor:'#fff'
});

var mapview = Titanium.Map.createView({
    mapType: Titanium.Map.STANDARD_TYPE,
    region: {latitude:0, longitude:0, 
        latitudeDelta:90, longitudeDelta:180},
    animate:true,
    regionFit:true,
    userLocation:true
});
win.add(mapview);

function updateMapLocation(e) {
    if (!e.success) { return; }

    var longitude = e.coords.longitude;
    var latitude = e.coords.latitude;

    var annotation = Ti.Map.createAnnotation({
        latitude:latitude,
        longitude:longitude,
        title:'Overlapping annotation',
        image:'images/annotation.jpg'
    });
    mapview.addAnnotation(annotation);

    var region = {latitude:latitude, longitude:longitude, latitudeDelta:0.05, longitudeDelta:0.05, animate:true};
    mapview.setLocation(region);
}

Titanium.Geolocation.purpose = "For testing";

var b = Ti.UI.createButton({title:'Add Annotation', style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED});
b.addEventListener('click', function(e) {
    if (Titanium.Platform.model == 'Simulator') {
        var l = {success:true, coords:{latitude:37.3317, longitude:-122.0307}};
        updateMapLocation(l);
    } else {
        Titanium.Geolocation.getCurrentPosition(updateMapLocation);
    }
});

var flexSpace = Titanium.UI.createButton({
    systemButton:Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE
});
var tb = Titanium.UI.createToolbar({bottom:0, items:[flexSpace,b,flexSpace]});
win.add(tb);

win.open();

Attachments

FileDateSize
annotation.jpg2011-04-15T03:11:08.000+0000817

Comments

  1. Stephen Tramer 2012-07-26

    Expected behavior.

JSON Source