Quantcast
Viewing all articles
Browse latest Browse all 8068

User placed annotations in google maps

So I'm running ti.map off my iPhone Retina 3.5 inch emulator and I want to let the user place their own pins then take that information and use it elsewhere. The problem is I can't seem to figure out how to place the pins. I've tried adding an event listener but it only fires when you select a pre-existing pin. I've looked over the documentation as well as the iOS Guide but they don't explain how to either. The rest of the map works fine and my code is identical to the documentation example except that the map view is added into a subview eventBG and done so when the user clicks a button, not before the window is opened.

.xml
<Alloy>
    <Window class="container">
        <ImageView id="btnMenu" onClick="backClick"></ImageView>
        <View id="menuBar">
            <Label id="userName"></Label>
        </View>
        <ImageView id="replyBtn" onClick="confirmEvent"></ImageView>
        <View id="eventBG">
.js
 
    var Map = require('ti.map');
    var mapview;
 
function openMap(){
    var mountainView = Map.createAnnotation({
    latitude:37.390749,
    longitude:-122.081651,
    title:"Appcelerator Headquarters",
    subtitle:'Mountain View, CA',
    pincolor:Map.ANNOTATION_RED,
    myid:1 // Custom property to uniquely identify this annotation.
});
 mapview = Map.createView({
    mapType: Map.NORMAL_TYPE,
    region: {latitude:33.74511, longitude:-84.38993,
            latitudeDelta:0.01, longitudeDelta:0.01},
    animate:true,
    regionFit:true,
    userLocation:true,
    annotations:[mountainView]
});
 
    $.eventBG.add(mapview);
// Handle click events on any annotations on this map.
mapview.addEventListener('click', function(evt) {
    Ti.API.info("Annotation " + evt.title + " clicked, id: " + evt.annotation.myid);
});
From the iOS guide it looks like what I'm going to have to do is set a annotation and just have the user drag it around. Is this my only course of action?

Viewing all articles
Browse latest Browse all 8068

Trending Articles