简体   繁体   English

使用收到的经度和纬度动态更新Google地图

[英]Dynamically update google maps with received longitudes and latitudes

I've written a java applet which sends longitudes and latitudes trough POST requests. 我编写了一个Java小程序,它通过POST请求发送经度和纬度。 I need to write a server page which will receive this data and dynamically shows a google map with the received points on it. 我需要编写一个服务器页面,它将接收此数据并动态显示带有接收点的google map。 (php/etc...) (PHP /等...)

I don't know how to start with this, because I really don't know what to do first. 我不知道如何开始,因为我真的不知道首先要做什么。

https://developers.google.com/maps/documentation/imageapis/ has all the information you need. https://developers.google.com/maps/documentation/imageapis/包含您需要的所有信息。

So you simply need to get a server page to recieve your POST data, parse the longitude and latitude and then get the image result from the URL below (look inside the src attribute). 因此,您只需要获取一个服务器页面来接收POST数据,解析经度和纬度,然后从下面的URL获取图像结果(请查看src属性内部)。

Should be fairly obvious what all the parameters are, zoom level on google maps and the size of the map in pixels. 应该很明显地看出所有参数是什么,谷歌地图的缩放级别以及以像素为单位的地图大小。 Alternatively if you just want this map displaying on a webbrowser you just output the img tag shown below 另外,如果您只想将此地图显示在网络浏览器上,则只需输出如下所示的img标签

<img src="http://maps.googleapis.com/maps/api/staticmap?center=-15.800513,-47.91378&zoom=11&size=200x200&sensor=false">

生成的地图

EDIT: The URL will dynamically generate the map each time you send a POST request. 编辑:每次您发送POST请求时,URL都会动态生成地图。 If you need the data to continuously change then maybe using POST requests isnt the best way to do it. 如果您需要数据不断变化,那么使用POST请求并不是最好的方法。 POST is best used for data which you want to send off to a server then do something with (generate a single map etc). POST最适合用于要发送到服务器然后进行处理(生成单个地图等)的数据。

As an example... The user wants a map of where a particular street is that they have clicked on > Send POST request > Get the map using the Google Maps URL and send this back/output to a webpage. 举例来说...用户想要一张他们单击的特定街道的地图>发送POST请求>使用Google Maps URL获取地图,然后将此信息发送回/输出到网页。

As an alternative you might want to look at the various Maps APIs on the site. 另外,您可能希望查看网站上的各种Maps API。 A better link for this would be https://developers.google.com/maps/ 一个更好的链接是https://developers.google.com/maps/

It's not quite clear what you are aiming to do so providing an example usage would help with a better answer. 尚不清楚您打算做什么,因此提供示例用法将有助于获得更好的答案。

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

相关问题 如何绘制从我的android应用发送到tomcat服务器的经度和纬度,并在该处的Google地图上进行绘制? - How can i plot the longitudes and latitudes sent from my android app to tomcat server and plot on the google maps there? 分别计算两个纬度和经度之间的时间? - Time Calculation between two latitudes and longitudes respectively? 仅获取2个经度或2个纬度的距离(以英里为单位) - Get distances in miles for 2 longitudes or 2 latitudes only 降低复杂性。 查找最接近的纬度和经度对 - Reduce Complexity. Find closest pair of latitudes and longitudes 得出一对纬度和经度之间的任何点纬度和经度 - derive any points latitude and longitude between a pair of Latitudes and Longitudes 从两个坐标获取所有经度和纬度 - Getting all latitudes and longitudes from two co-ordinates 更新Google地图上的位置 - Update location on google maps 如何从两个地方的经度和纬度获得一个地方到另一个地方的方向? - how to get direction of one place to another from latitudes and longitudes of both place? Google Maps Api动态获取经时 - Google Maps Api get lat long dynamically 在 Spring(MVC 或 Boot)中动态添加 Google 地图 - Adding Google Maps dynamically in Spring (MVC or Boot)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM