我们如何从Google Direction API建议的替代路线默认获得从A点到B点的最短距离路线?默认情况下,它根据当前的交通状况为我们提供最短的持续时间路线.我注意到如果你打开"provideRouteAlternatives = true",google会响应多个备用路由,我想知道我们是否可以向Google API发送一个参数,以便它始终返回最短距离路径
我想在两个纬度经度之间绘制路径.这是我的MapsActivity.java.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment)
getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
find = (Button) findViewById(R.id.btnFindPath);
or = (EditText) findViewById(R.id.etOrigin);
dest = (EditText) findViewById(R.id.etDestination);
find.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sendRequest();
}
});
}
public void sendRequest(){
String origin = or.getText().toString();
String destination = dest.getText().toString();
if(origin.isEmpty()){
Toast.makeText(this,"Please Enter the Origin" , Toast.LENGTH_SHORT).show();
}
if(destination.isEmpty()){
Toast.makeText(this,"Please Enter the Destination" , …Run Code Online (Sandbox Code Playgroud) 当我们为Google Maps Direction Api 设置Key限制为NONE时,它运行正常.
但是当我们为Android应用程序设置密钥限制并提供正确的软件包名称和SHA-1证书时 - 它表示请求已从Google Api响应中拒绝.
任何已知的解决方案?
android google-maps google-maps-api-2 google-maps-android-api-2 google-maps-direction-api
我们正在调用google指令api来计算往返行程值.一般来说它完美无缺.然而,我遇到了一个用例,它无法提出任何路由.但是,当我们使用具有相同origin,destination,waypoints和travelMode的js google.maps.DirectionsService版本时,它可以正常工作.
失败的电话是:https://maps.googleapis.com/maps/api/directions/json?origin = -33.92873,18.458879&destination=-33.92873,18.458879&waypoints= via: -33.9403,18.666731&mode=driving&key=
回应是
{
"geocoded_waypoints" : [ {}, {}, {} ],
"routes" : [],
"status" : "ZERO_RESULTS"
}
Run Code Online (Sandbox Code Playgroud) javascript google-maps google-maps-api-3 google-maps-direction-api
我在Android中创建了一个应用程序,其功能与Google Map相同,可以找到指向特定位置的方向.
我有谷歌方向API收到的从一个地方到另一个地方的绘制路线(折线).我的问题是,我想将当前的流量数据仅放在特定的多边形线上.
如果我们从网上找到方向而不是我们没有获得任何流量数据,但如果我们从移动设备上的谷歌地图应用程序中找到它,那么我们就能看到它.
有谁知道如何解决方案?请给我一个线索!
我从以下URL获得了json响应:
JSON路径routes[x].legs[y].steps[z].polyline.points:
"azq〜FHC {uOAlB jB表示^ P P乙@ V□的|??????【J @为fA XA @ XA H +乙˚F@ TA @的xD H + BNA @ |?????甲@ rB中@ ˚F@ @@ d v□的AXB d @ AZEzA BIjB @Cx @ EzAAlC F F T B˚F@ DhHBhD 5 R升5 R |???????????????CCpDAj @ E | DGnDKzCCb @ OtBa @ rFGfAAb @?@?FAp @?
ADbJD|F@bF@@@fERhd@BrEFdDBtBAvBAx@@l@?n@@^@bANnQ?rABnM?jC?hH@fA?@BF?vC?hB?@BpM?@?j @@ p @@ | KB~Q @ pFBbHBvF @ z @?f @@ jB?nA @ z @ DzD @ VJ ~CLfC\| E?B?@ HnANtAVpDRpCLbB ^ dFTxC …
我正在尝试在Google Maps静态地图上显示来自Google Maps Directions api的路径。路线api调用的网址如下所示:
https://maps.googleapis.com/maps/api/directions/json?origin=lübeck&destination=hamburg&key=MY_API_KEY
我得到一个包含所有信息的有效json响应。然后,我想通过此api调用在静态地图上显示路径概述的编码折线:
https://maps.googleapis.com/maps/api/staticmap?sensor=false&size=860x600&path=enc:THE_ENCODED_POLYLINE
Run Code Online (Sandbox Code Playgroud)
静态地图不会显示路径。我怀疑路线api返回的编码折线格式错误或不完整。如果将返回的编码折线输入到Google的交互式折线解码器中,则会在末尾自动添加“ @”字符。产生的折线将显示在静态地图上,但与方向不匹配。
我在不同城市之间的路径上进行了准确的工作流程,完全没有问题。是否有人对这个示例有什么想法有任何想法。
google-maps polyline google-maps-static-api google-maps-direction-api
google-maps ×5
android ×3
directions ×3
java ×1
javascript ×1
json ×1
kotlin ×1
php ×1
polyline ×1