1. #1
    Sencha Premium Member
    Join Date
    Feb 2011
    Posts
    75
    Vote Rating
    1
    ShaneTex is on a distinguished road

      0  

    Default CityBars with Map Markers

    CityBars with Map Markers


    Ok, so I have worked through the tutorial and video, and I can view all bars, etc view the list and Map, but how do I show the locations on the map, I have it zooming to the location, but I want to add a marker and then add a listener for those markers. When I do this the markers never display, and the click events never fire. I have done this prior to MVC with sencha touch 1.x and it worked. I am very new to the designer, and 2.0. What am I doing wrong.

    Here is the code:
    Code:
       var center = new google.maps.LatLng(location.coords.latitude,location.coords.longitude);
         var detailsMap = Ext.getCmp('detailMap');    var currentBookmark = new google.maps.Marker({
            map: detailsMap.map,
            icon: './img/nothome.png',
            position: center
        });
    It runs, or I don't get an error, but nothing displays.

    If I use a addListener:

    Code:
        onMapMaprender: function(map, gmap, options) {
            me = this;
            //alert(map);
            me.Map = map;
            google.maps.event.addListener(map, 'click', function (event) {
                alert(event.latLng);        
            });
        },
    I don't get an error, but it never fires.

    Any help would be greatly appreciated

  2. #2
    Sencha Premium Member
    Join Date
    Jan 2011
    Posts
    1
    Vote Rating
    0
    jfgriggs is on a distinguished road

      0  

    Default


    Try using:

    var center = new google.maps.LatLng(location.coords.latitude,location.coords.longitude);
    var detailsMap = Ext.getCmp('detailMap');
    var currentBookmark = new google.maps.Marker({
    map: detailsMap.getMap(),
    icon: './img/nothome.png',
    position: center
    });

  3. #3
    Sencha Premium Member
    Join Date
    Feb 2011
    Posts
    75
    Vote Rating
    1
    ShaneTex is on a distinguished road

      0  

    Default Fixed

    Fixed


    Thank you for your help, that was it exactly..

  4. #4
    Sencha User
    Join Date
    Mar 2010
    Posts
    2
    Vote Rating
    0
    kuvark is on a distinguished road

      0  

    Default getMap() is null

    getMap() is null


    I use this sample and just want to set marker. but all the time map.getMap() is null. I'm using architect 2 and sencha touch 2.2

  5. #5
    Sencha Premium Member
    Join Date
    Feb 2011
    Posts
    75
    Vote Rating
    1
    ShaneTex is on a distinguished road

      0  

    Default


    Make sure you have an OnMapMaprender defined. See below

    onMapMaprender: function(map, gmap, eOpts) {
    var me = this;
    mapCtrl.Map = map;
    /*
    mapCtrl.Map = map;
    currentMarker = null;
    markerIndex = 0;
    //storeIndex = 100;


    recordIndex = -1;
    markerArray = [];
    markerIconArray = [];
    currentStatus = null;
    */
    latlngBounds = new google.maps.LatLngBounds();


    //Add listener for map click
    google.maps.event.addListener(map.getMap(), 'click', function (event) {
    //alert(event.latLng);
    me.addMarkerByClick(event.latLng);
    });
    }

Thread Participants: 2

Tags for this Thread