如何格式化GPS经纬度

如何格式化GPS经纬度

本文介绍了如何格式化GPS经纬度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在android(java)中,当您使用getlatitude()函数获取当前的纬度和经度时,会以十进制格式获取坐标:

In android(java) when you get the current latitude and longitude using the function getlatitude() etc you get the coordinates in decimal format:

我想将其转化为度和小数分钟,看起来像这样:

I want to get this into degrees and decimal minutes to look something like this:


推荐答案

要从小数转换为度,您可以按照以下步骤进行操作

to conver from decimals to degrees you can do as follow

String strLongitude = Location.convert(location.getLongitude(), Location.FORMAT_DEGREES);
String strLatitude = Location.convert(location.getLatitude(), Location.FORMAT_DEGREES);

引用是。

编辑

我尝试了以下操作并获得输出:

I have tried following thing and get the output:

strLongitude = Location.convert(location.getLongitude(), Location.FORMAT_DEGREES);
strLatitude = Location.convert(location.getLatitude(), Location.FORMAT_DEGREES);

OUTPUT : Long: 73.16584: Lat: 22.29924

strLongitude = Location.convert(location.getLongitude(), Location.FORMAT_SECONDS);
strLatitude = Location.convert(location.getLatitude(), Location.FORMAT_SECONDS);

OUTPUT : Long: 73:9:57.03876: Lat: 22:17:57.26472

strLongitude = Location.convert(location.getLongitude(), Location.FORMAT_MINUTES);
strLatitude = Location.convert(location.getLatitude(), Location.FORMAT_MINUTES);

OUTPUT : Long: 73:9.95065: Lat: 22:17.95441

根据您的要求尝试其他选项

Try different option as per your requirement

这篇关于如何格式化GPS经纬度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 06:47