如何将 Java 与 google maps api 一起使用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19367922/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 16:32:01  来源:igfitidea点击:

How use Java with google maps api?

javagoogle-maps-api-3

提问by Alan Lopez

Java with Google maps api

带有谷歌地图 API 的 Java



I'd like to begin a project with Java that needs a map. I've been thinking about either Google Maps or another Open Source map. How would I implement this?

我想用 Java 开始一个需要地图的项目。我一直在考虑使用 Google 地图或其他开源地图。我将如何实现这一点?

采纳答案by Misha Zaslavsky

First of all, I would offer you to use google maps api, they are using REST services and they are very good.

首先,我会建议您使用 google maps api,他们正在使用 REST 服务,并且非常好。

Here is a short explantation: You need to make an HTTP request with a URL with the parameters you wish (such as the location - longtitude, latitude, the address, and more), this code should be made in java. If you did everything correct, you will recieve a response of type (xaml or json, depends on the URL you sent, it is preferable to use JSON).

这是一个简短的解释:您需要使用带有您希望的参数(例如位置 - 经度、纬度、地址等)的 URL 发出 HTTP 请求,此代码应使用 java 编写。如果您做的一切都正确,您将收到类型(xaml 或 json,取决于您发送的 URL,最好使用 JSON)的响应。

After you receive the response you need to deserialize it, which seems to be hard, but is very simple, for example JSON has many ways and built in methods to do it.

收到响应后,您需要对其进行反序列化,这似乎很难,但非常简单,例如 JSON 有很多方法和内置方法可以做到这一点。

And then you can do whatever you wish with the objects you received.

然后你可以对你收到的物品做任何你想做的事情。

So here are some links:

所以这里有一些链接:

Google API - https://developers.google.com/maps/documentation/geocoding/?hl=enand https://developers.google.com/maps/documentation/staticmaps/?hl=iw&csw=1

Google API - https://developers.google.com/maps/documentation/geocoding/?hl=enhttps://developers.google.com/maps/documentation/staticmaps/?hl=iw&csw=1

JSON Deserialize - http://james.newtonking.com/json/help/index.html?topic=html/LINQtoJSON.htmor a better one (if you want to make many requests) - http://blogs.msdn.com/b/webdev/archive/2012/12/18/paste-json-as-classes-in-asp-net-and-web-tools-2012-2-rc.aspx

JSON 反序列化 - http://james.newtonking.com/json/help/index.html?topic=html/LINQtoJSON.htm或更好的(如果你想发出很多请求) - http://blogs.msdn。 com/b/webdev/archive/2012/12/18/paste-json-as-classes-in-asp-net-and-web-tools-2012-2-rc.aspx