标签: map-directions

在不使用javascript api的情况下显示google direction web service的结果

我正在开发一个应用程序,它将在2个点之间找到方向,在谷歌地图上显示它并将其存储在服务器端,以便我可以在需要时再次渲染它以将一条路线与另一条路线进行比较.
我已成功使用谷歌地图api web服务找到路线,我也使用谷歌地图javascript v3找到路线并使用DirectionsRenderer在地图上显示它.
这两个服务都返回类似的JSON,其中包含JSON属性名称的不同(参见下面的示例1).更重要的是,JS api将lat/lng的不同属性名称从一个调用返回到另一个调用(参见下面的示例2).

所以问题是我无法使用从服务器端Web服务调用获得的JSON并直接将其传递给javascripts DirectionRenderer类来显示路由.而且,每次我在地图上显示路线时,我都要进行JS调用.这将导致不必要的配额使用.有没有更好的方法来做到这一点.我已经完成了以下问题,但我实际上无法在这里这里得到答案

例1:

Web服务呼叫结果:

{
    "routes" : [
      {
         "bounds" : {
            "northeast" : {
               "lat" : 12.9198217,
               "lng" : 77.6124895
            },
            "southwest" : {
               "lat" : 12.912811,
               "lng" : 77.60924989999999
            }
         },
          .....
Run Code Online (Sandbox Code Playgroud)

这没有"路径"属性.

Javascript V3调用结果:

{
"routes": [
    {
        "bounds": {
            "ta": {
                "d": 12.91281,
                "b": 12.919820000000001
            },
            "ga": {
                "b": 77.60925,
                "d": 77.61249000000001
            }
        },
        ......
        "path": [
                            {
                                "d": 12.913920000000001, …
Run Code Online (Sandbox Code Playgroud)

google-maps google-maps-api-3 map-directions

6
推荐指数
1
解决办法
1656
查看次数

谷歌地图api可以进行语音导航吗?

如何使用google map api v3激活基于语音的路线?我已经实现了从起点到终点给出方向的地图.但现在我想听听我当前位置的名称.请帮忙 ?我在ios UIWebView中实现了它,所以我从GPS获取当前位置.现在我每2秒更新一次,但我会添加基于语音的指示.这怎么可能?请帮忙

javascript navigation voice google-maps-api-3 map-directions

5
推荐指数
1
解决办法
6214
查看次数

如何为iOS应用程序构建内部地图导航?

我有下面提到的要求:

  • 已经有一个平面图地图图像
  • 首先检测地板上的当前位置
  • 然后使用平面图地图图像选择目的地位置
  • 现在应用程序应该为该源提供到目标路径的方向和距离
  • 这就像谷歌方向的工作方式,但它的内部地图需要.

例如, - 用户的当前位置是:在他的办公桌 - 会议室#11的位置 - 因此应用程序应在地图/平面图图像上提供方向和距离更新.

任何建议/帮助都会很棒.

提前致谢

navigation map-directions ios

5
推荐指数
1
解决办法
2946
查看次数

向手机发送指示

我在开车时但在网页上使用Google Direction API获取用户的路线。我希望一旦用户对方向感到满意,就可以将其发送到他们的手机,汽车等。他们可以在其中使用谷歌地图导航。

google-maps map-directions

5
推荐指数
0
解决办法
454
查看次数

Google maps API - 未捕获的ReferenceError:未定义directionsService

我试图在我的网站上使用的地图上使用方向,但有一个错误不断弹出,我不知道如何摆脱它!

未捕获的ReferenceError:未定义directionsService

这是我使用的代码

$(window).load(function () {
    var directionsDisplay;
    var directionsService = new google.maps.DirectionsService();
    var map;
});
$(window).load(function () {
        initialize();
    });

function initialize() {
  directionsDisplay = new google.maps.DirectionsRenderer();
  var chicago = new google.maps.LatLng(41.850033, -87.6500523);
  var mapOptions = {
    zoom:7,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    center: chicago
  }
  map = new google.maps.Map(document.getElementById("map"), mapOptions);
  directionsDisplay.setMap(map);
  directionsDisplay.setPanel(document.getElementById("directionsPanel"));
}

function calcRoute() {
  var start = new google.maps.LatLng(54.986136, -1.537945);
  var end = new google.maps.LatLng(41.850033, -87.6500523);

  var request = {
    origin:start,
    destination:end,
    travelMode: google.maps.TravelMode.DRIVING
  };
  console.log(request);
  if (request==true)
  { …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps google-maps-api-3 map-directions

4
推荐指数
1
解决办法
9135
查看次数

如何在构建路由后更改google map api中路由的颜色

你会发现许多已经答案显示如何在其上构建具有不同颜色的路线如何在谷歌地图v3中更改路线的颜色

我想知道如何在已经构建和渲染后更改颜色.

我在地图上显示了许多不同的路线,但我想显示红色或深色,如果此方向点处于活动状态并将其他路线颜色更改为灰色,直到其中一个处于活动状态.

码:

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

function initialize() {
  directionsDisplay = new google.maps.DirectionsRenderer({
    polylineOptions: {
      strokeColor: "red"
    }
  });

  var mapOptions = {
    zoom:7,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    center: {lat: 41.850033, lng: -87.6500523}
  }
  map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
  directionsDisplay.setMap(map);
}

function calcRoute() {
  var start = document.getElementById('start').value;
  var end = document.getElementById('end').value;
  var request = {
      origin:start,
      destination:end,
      travelMode: google.maps.DirectionsTravelMode.DRIVING
  };
  directionsService.route(request, function(response, status) {
    if (status == google.maps.DirectionsStatus.OK) {
      directionsDisplay.setDirections(response);
    }
  });
} …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps google-maps-api-3 map-directions

4
推荐指数
1
解决办法
8468
查看次数

在 Google Maps API V3 中计算方向(航向)

我想知道从出发地到目的地的方向。

\n\n

只是想知道角度值\xe2\x80\x8b\xe2\x80\x8b 中的方向。

\n\n

在上图中,角度值可能在 350-360 之间。\n(图片来源:\n https://maps.google.com/maps?saddr=Dr+NS+Hardikar+Rd&daddr=Rithala+Metro+,+里塔拉+路,+扇区+12,+罗希尼,+新+德里,+德里,+印度&地理代码=FYfstQEdJn-YBA%3BFY8-tgEd3Y-YBCnlvvwRTAENOTHixeyZbhPwSA&sll=28.697665,77.11956&sspn=0.062715,0.1第1055章

\n\n

我无法上传图片。对不起。

\n\n

我该如何计算?

\n

google-maps-api-3 map-directions

1
推荐指数
1
解决办法
9235
查看次数

android从maps.google.com指示获取持续时间

目前我正在使用此代码查询谷歌地图以查找从地址到另一个地址的路线,然后我只是从其GeometryCollection的mapview上绘制它.但是这还不够,我还需要从kml中提取总预期持续时间.有人可以提供一些示例代码来帮助我吗?谢谢

StringBuilder urlString = new StringBuilder();
urlString.append("http://maps.google.com/maps?f=d&hl=en");
urlString.append("&saddr=");//from
urlString.append( Double.toString((double)src.getLatitudeE6()/1.0E6 ));
urlString.append(",");
urlString.append( Double.toString((double)src.getLongitudeE6()/1.0E6 ));
urlString.append("&daddr=");//to
urlString.append( Double.toString((double)dest.getLatitudeE6()/1.0E6 ));
urlString.append(",");
urlString.append( Double.toString((double)dest.getLongitudeE6()/1.0E6 ));
urlString.append("&ie=UTF8&0&om=0&output=kml");
//Log.d("xxx","URL="+urlString.toString());
// get the kml (XML) doc. And parse it to get the coordinates(direction route).
Document doc = null;
HttpURLConnection urlConnection= null;
URL url = null;
try
{
    url = new URL(urlString.toString());
    urlConnection=(HttpURLConnection)url.openConnection();
    urlConnection.setRequestMethod("GET");
    urlConnection.setDoOutput(true);
    urlConnection.setDoInput(true);
    urlConnection.connect();
    dbf = DocumentBuilderFactory.newInstance();
    db = dbf.newDocumentBuilder();
    doc = db.parse(urlConnection.getInputStream());
    if(doc.getElementsByTagName("GeometryCollection").getLength()>0)
    {
        //String path = doc.getElementsByTagName("GeometryCollection").item(0).getFirstChild().getFirstChild().getNodeName();
        String path = doc.getElementsByTagName("GeometryCollection").item(0).getFirstChild().getFirstChild().getFirstChild().getNodeValue() …
Run Code Online (Sandbox Code Playgroud)

java android google-maps duration map-directions

0
推荐指数
1
解决办法
7906
查看次数

谷歌地图方向与多个方向与颜色

我需要在地图方向上填充以下数据

dataset 1
    [
        [lat, lon],
        [lat, lon],
        [lat, lon],
    ],
dataset 2
    [
        [lat, lon],
        [lat, lon],
        [lat, lon],
    ],   
So On ... 
Run Code Online (Sandbox Code Playgroud)

所有数据集都应具有具有唯一颜色的路线,并且任何数据集都可以超过 8 个航点限制。我能够通过遵循https://lemonharpy.wordpress.com/2011/12/15/working-around-8-waypoint-limit-in-google-maps-directions-api/等在线教程来修复 8 个路点限制在 Google 地图 v3 中绘制超过 8 个航点

但我发现没有办法为每个数据集获取不同颜色的路线。

这是我的代码

<style>
#map {
       height: 1080px;
       width: 100%;
       border: 1px solid #000;  
     }

</style>

<div id="map"></div>
<script>
function initMap() {
    //console.log("sdsfsd");
    map = new google.maps.Map(document.getElementById('map'), {
      zoom: 14,
      center: {lat: 28.6247, lng: 77.3731},
      disableDefaultUI:true,
      //28.6247375!4d77.3731819
    });

    var directionsService = new …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps google-maps-api-3 map-directions

0
推荐指数
1
解决办法
6167
查看次数