2
votes

i am new in sencha touch. i have integrated google map using sencha touch and display marker on user current location. now, i want to display direction from source address to destination address on map.

the sample like this, https://maps.google.com/maps?saddr=21.220901,72.829056&daddr=20.915907,72.871628

i want display only map view with direction path. how to display direction between two places on goole map using sencha toch ?

1

1 Answers

2
votes

here is code,

function directionMap(src,dest){
   // alert('calling');

    var directionsService = new google.maps.DirectionsService();
    var directionsDisplay = new google.maps.DirectionsRenderer();

    var map = new google.maps.Map(document.getElementById('map'), {
    zoom:10,
    mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    directionsDisplay.setMap(map);
    var request = {
   // origin: '21.220901,72.829056',
   // destination: '20.915907,72.871628',

        origin: src,
        destination: dest,
    travelMode: google.maps.DirectionsTravelMode.DRIVING
    };

    directionsService.route(request, function(response, status) {
    if (status == google.maps.DirectionsStatus.OK) {
    directionsDisplay.setDirections(response);
    }
    });
    }

just call directionMap function with source and destination it will draw path on map.