Results 1 to 3 of 3

Thread: Dispay marker on Current position of user at map

  1. #1
    Sencha User
    Join Date
    Mar 2013
    Posts
    2

    Default Dispay marker on Current position of user at map

    I am able to display map on screen and get the current positions of latitude and longitude. However I want to display a marker at the position of those latitude and longitude values. I have tried by adding a listener when map is rendered. Below is the code. But no marker shows up on the screen. Any pointers on how to get the marker displayed at the current position will be really helpful..

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Secha</title>

    <script src="touch/sencha-touch-all.js" type="text/javascript"></script>
    <script src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
    <link href="touch/resources/css/sencha-touch.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
    Ext.application({
    name: 'MapApp',

    launch: function() {
    var lat,lng;

    //get latitude and longititude values

    Ext.device.Geolocation.getCurrentPosition({
    success: function(position) {
    lat = position.coords.latitude;

    lng = position.coords.longitude;
    alert(lat);
    alert(lng);
    Ext.Viewport.add( {
    xtype:'map',
    useCurrentLocation:true,
    fullscreen: true,
    layout:'fit',
    listeners : {
    maprender : function() {
    alert('map rendered');
    var marker = new google.maps.Marker({
    position: new google.maps.LatLng(lat,lng),
    title : 'testing',

    });
    }
    }

    });
    },
    failure: function() {
    alert('something went wrong!');
    }
    });
    }
    });


    </script>
    </head>
    <body></body>


    </html>

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379

    Default

    The Geolocation class that is being used to get the current position is on the map via the getGeo method. From that Geolocation class you can get the coords.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  3. #3
    Sencha User
    Join Date
    Mar 2013
    Posts
    2

    Default

    I have already got the coordinates. However this was due to missing map attribute in function being called on maprender.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •