简体   繁体   English

使用“com.google.android.gms.maps.GoogleMap”,我可以像在 maps.google.com 上一样绘制路线吗?

[英]Using “com.google.android.gms.maps.GoogleMap”, can I draw a route as I can on maps.google.com?

I expected it to be possible to get directions/draw a route between two points using Google Maps for Android (please note: Google Maps, NOT Google Navigation).我希望可以使用 Android 版谷歌地图获取路线/绘制两点之间的路线(请注意:谷歌地图,而不是谷歌导航)。

I just got the "com.google.android.gms.maps.GoogleMap" (using MapFragment) to work, but I dont see any methods for drawing/getting a route between two points.我刚刚让“com.google.android.gms.maps.GoogleMap”(使用 MapFragment)工作,但我没有看到任何绘制/获取两点之间路线的方法。 So I am suspecting that this cannot be done.所以我怀疑这是不可能做到的。

Can someone verify or deny this?有人可以验证或否认这一点吗? =) =)

PS: I know about "Google Navigation". PS:我知道“谷歌导航”。 It works to use an Intent to get a route there, but the problem is I cannot get it to be "inline" in my app, which in a way isn't ideal.它可以使用 Intent 在那里获取路线,但问题是我无法在我的应用程序中将其“内联”,这在某种程度上并不理想。 So I was looking at Maps instead.所以我正在看地图。

but I dont see any methods for drawing/getting a route between two points.但我没有看到任何在两点之间绘制/获取路线的方法。 So I am suspecting that this cannot be done.所以我怀疑这是不可能做到的。

Use a Polyline to draw the route.使用Polyline绘制路线。

"Getting a route" was not part of Maps V1 and is not part of Maps V2. “获取路线”不是 Maps V1 的一部分,也不是 Maps V2 的一部分。 You will have to find some Web service that will give you route information.您必须找到一些可以为您提供路线信息的 Web 服务。

Also, I strongly encourage you to have qualified legal counsel review the terms and conditions for using Maps V2, to confirm that what you are trying to do is within the bounds of that agreement, which has specific clauses related to providing navigation assistance.此外,我强烈建议您让合格的法律顾问查看使用 Maps V2 的条款和条件,以确认您尝试做的事情在该协议的范围内,该协议具有与提供导航帮助相关的特定条款。

Getting a Route is discussed by Google Developers using API V2..API V1 is really not the proper answer to do it..Here is the API V2 code Google Developers 使用 API V2 讨论了获取路由。API V1 确实不是正确的答案。这是 API V2 代码

public void setupLine(LatLng startLocation){
     //set up path
     PolylineOptions line=new PolylineOptions().add(startLocation).add(startLocation).color(mLineColour);
     mPath=mMap.addPolyline(line);
     mPath.setGeodesic(true);

     //Add 2 points
      pathPoints=new ArrayList<LatLng>(2);
      pathPoints.add(startLocation);//origin
      pathPoints.add(startLocation);//destination - updated later
    }

private void updateLine(LatLng position){
      //replace location
      pathPoints.set(1, position);

      //assign new points to path
      mPath.setPoints(pathPoints);

    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Android应用程序com.google.android.gms.maps.GoogleMap中导入此程序包(库) - how can i import this packages (Libraries) in my android application com.google.android.gms.maps.GoogleMap com.google.android.gms.maps.GoogleMap com.google.android.gms.maps.MapFragment.getMap()&#39;对空对象的引用 - com.google.android.gms.maps.GoogleMap com.google.android.gms.maps.MapFragment.getMap()' on a null object reference Android:使用com.google.android.gms.maps.GoogleMap设置区域的默认缩放级别 - Android : Setting default zoom level for an area with com.google.android.gms.maps.GoogleMap com.sun.tools.javac.code.Symbol$CompletionFailure: class file for com.google.android.gms.maps.GoogleMap not found - com.sun.tools.javac.code.Symbol$CompletionFailure: class file for com.google.android.gms.maps.GoogleMap not found 我在哪里可以找到android maps.google.com意图URI的文档 - Where can I find documentation of android maps.google.com intent URI com.google.android.gms.maps.GoogleMap.SnapshotReadyCallback无法解析 - com.google.android.gms.maps.GoogleMap.SnapshotReadyCallback cannot be resolved 如何在Android上的GoogleMap中修复com.google.android.gms.maps.model.Marker com.google.android.gms.maps.GoogleMap.addMarker - How to fix com.google.android.gms.maps.model.Marker com.google.android.gms.maps.GoogleMap.addMarker in GoogleMap on Android 我可以为maps.google.com的路线网址添加标题吗? - Can I add titles to locations for the directions url for maps.google.com? com.google.android.gms.maps.GoogleMap.addMarker(com.google.android.gms.maps.model.MarkerOptions)”上的空对象引用 - com.google.android.gms.maps.GoogleMap.addMarker(com.google.android.gms.maps.model.MarkerOptions)' on a null object reference android从maps.google.com路线获取持续时间 - android get duration from maps.google.com directions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM