如何使用java中的google api从两组坐标中获取方向

时间:2022-08-22 11:15:50

Can't really find anything. But I am writing a javafx project where the user inputs latitude/longitude and get returned with directions. I am looking for concrete examples to do this. I know I have to send have a specific url from google api. But I have no clue how to use the url and get the json format back and parse it.

真的找不到任何东西。但我正在编写一个javafx项目,用户输入纬度/经度并返回路线。我正在寻找具体的例子来做到这一点。我知道我必须发送一个来自谷歌api的特定网址。但我不知道如何使用url并获取json格式并解析它。

3 个解决方案

#1


1  

You can use request parameters including the origin and destination in Google Maps Directions API and you should be able to get directions.

您可以在Google Maps Directions API中使用请求参数,包括来源和目的地,您应该可以获得路线。

#2


0  

You can use Google Map's Web API

您可以使用Google Map的Web API

Here's the documentation for it https://developers.google.com/maps/documentation/directions/intro#TravelModes

这是它的文档https://developers.google.com/maps/documentation/directions/intro#TravelModes

#3


0  

The Google Maps API provides a direction API, this gives a set a directions between two points.

Google Maps API提供了方向API,可以设置两点之间的方向。

Here's an example with using a JSON response, you can also use XML as documented in the API: http://maps.googleapis.com/maps/api/directions/json?origin=37.421957,-122.084197&destination=37.431865,-122.103789

以下是使用JSON响应的示例,您还可以使用API​​中记录的XML:http://maps.googleapis.com/maps/api/directions/json?origin = 37.421957,-122.084197&destination = 37.431865,-122.103789

See this for full reference: https://developers.google.com/maps/documentation/directions/intro

请参阅此内容以获取完整参考:https://developers.google.com/maps/documentation/directions/intro

#1


1  

You can use request parameters including the origin and destination in Google Maps Directions API and you should be able to get directions.

您可以在Google Maps Directions API中使用请求参数,包括来源和目的地,您应该可以获得路线。

#2


0  

You can use Google Map's Web API

您可以使用Google Map的Web API

Here's the documentation for it https://developers.google.com/maps/documentation/directions/intro#TravelModes

这是它的文档https://developers.google.com/maps/documentation/directions/intro#TravelModes

#3


0  

The Google Maps API provides a direction API, this gives a set a directions between two points.

Google Maps API提供了方向API,可以设置两点之间的方向。

Here's an example with using a JSON response, you can also use XML as documented in the API: http://maps.googleapis.com/maps/api/directions/json?origin=37.421957,-122.084197&destination=37.431865,-122.103789

以下是使用JSON响应的示例,您还可以使用API​​中记录的XML:http://maps.googleapis.com/maps/api/directions/json?origin = 37.421957,-122.084197&destination = 37.431865,-122.103789

See this for full reference: https://developers.google.com/maps/documentation/directions/intro

请参阅此内容以获取完整参考:https://developers.google.com/maps/documentation/directions/intro