首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在Google Maps API中沿原点和目的地之间的路线获取地点(例如加油站)

如何在Google Maps API中沿原点和目的地之间的路线获取地点(例如加油站)
EN

Stack Overflow用户
提问于 2013-06-25 03:47:44
回答 1查看 16K关注 0票数 22

你能让我知道是否有可能获得所有地方的列表,例如沿路线在谷歌地图API的起点和目的地之间的加油站?Here是一个链接,我试图列出所有加油站或休息区域(或谷歌地图API支持的任何地方类型)之间的两点ans方向支持的路线。

到目前为止,我的代码如下:

var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
var haight = new google.maps.LatLng(49.216364,-122.811897);
var oceanBeach = new google.maps.LatLng(50.131446,-119.506838);

function initialize() {
  directionsDisplay = new google.maps.DirectionsRenderer();
  var mapOptions = {
  zoom: 14,
  mapTypeId: google.maps.MapTypeId.ROADMAP,
  center: haight
}
  map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
  directionsDisplay.setMap(map);

    calcRoute();
 }

function calcRoute() {
  var request = {
  origin: haight,
  destination: oceanBeach,
  travelMode: google.maps.TravelMode.DRIVING
  };
  directionsService.route(request, function(response, status) {
   if (status == google.maps.DirectionsStatus.OK) {
       directionsDisplay.setDirections(response);
      }
 });
}

google.maps.event.addDomListener(window, 'load', initialize);

编辑后的零件:

// Make the directions request
  directionService.route(request, function(result, status) {
    if (status == google.maps.DirectionsStatus.OK) {
      directionsRenderer.setDirections(result);

      // Box around the overview path of the first route
      var path = result.routes[0].overview_path;
      var boxes = routeBoxer.box(path, distance);
      drawBoxes(boxes);
    } else {
      alert("Directions query failed: " + status);
    }

      for (var i = 0; i < boxes.length; i++) {
  var bounds = box[i];
  // Perform search over this bounds 
}



  });
}
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17283826

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档