Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Draggable annotation is duplicating itself? - iPhone iOS 7.1.1 - Ti.3.2.3GA

$
0
0

Hi Guys. I am adding a single annotation to a map which I've set to draggable. I am then resetting the location and geocoding the new location when the pin is dropped allowing my user to move the location at their will. This all works well, but sometimes the pin is duplicating itself when its picked up leaving the original annotation in place...

var annotation = function(address, lat, lon){
    // Now add our location
    var yourLocation = Alloy.Globals.Map.createAnnotation({
        // animate: true,
        pincolor: Alloy.Globals.Map.ANNOTATION_RED,
        draggable: true,
        title:"Accident Location",
        subtitle: address.substring(0, 25)+'...',
        latitude: lat,
        longitude: lon
    });
    $.mapview2.addAnnotation(yourLocation);
    $.mapview2.selectAnnotation(yourLocation);
    // Centre the map after 500ms (to bypass bug)
    setTimeout(function(){
        $.mapview2.location = {latitude: lat, longitude: lon,latitudeDelta: 0.01,longitudeDelta: 0.01};
    },500);
};
 
$.mapview2.addEventListener("pinchangedragstate", function(e) {
    if(e.newState == 0)
    {
        // Set the subtitle to Loading, set the map to centre on the new location and geocode the new location.
        e.annotation.subtitle = 'Loading...';
        $.mapview2.setLocation({latitude: e.annotation.latitude,longitude: e.annotation.longitude});
        geocode(e.annotation.latitude,e.annotation.longitude);
    }
});

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>