我是 sencha touch 的新手。 我已经使用 sencha 触摸集成了谷歌地图,并在用户当前位置上显示标记。 现在,我想在 map 上显示从源地址到目标地址的方向。
像这样的样本, https://maps.google.com/maps?saddr=21.220901,72.829056&daddr=20.915907,72.871628
我只想显示带有方向路径的 map View 。 如何使用 sencha toch 在 goole map 上显示两个地点之间的方向?
最佳答案
这是代码,
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);
}
});
}
只需调用带有源和目的地的 DirectionMap 函数,它就会在 map 上绘制路径。
关于google-maps - 使用 sencha touch 集成谷歌地图方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14749495/