问XE7开发android应用:怎么定位当前在哪个城市?

Jonix 2015-04-20 11:38:29
问XE7开发android应用:怎么定位当前在哪个城市?
...全文
605 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
hyz_cs 2015-06-14
  • 打赏
  • 举报
回复
百度地图有这些接口可以用,自己去看看吧.
哈啤猫 2015-06-13
  • 打赏
  • 举报
回复
高德的偏差更离谱。。。。我特么滴天天睡在河里???
宝龙哥 2015-04-20
  • 打赏
  • 举报
回复
完整代码,因为不知道谷歌的这个位置服务是否被某某,所以你自己测试一下

	auto lDecSeparator = FormatSettings.DecimalSeparator;
	auto lSettings = FormatSettings;
	FormatSettings.DecimalSeparator = '.';

	ListBoxItemLatitude->ItemData->Detail =
		ListBoxItemLatitude->ItemData->Detail.sprintf(L"%2.6f", newLocation.Latitude);
	ListBoxItemLongitude->ItemData->Detail =
		ListBoxItemLongitude->ItemData->Detail.sprintf(L"%2.6f", newLocation.Longitude);

	auto lLongitude = FloatToStr(newLocation.Longitude, lSettings);
	String URLString = "";
	URLString = URLString.sprintf(L"https://maps.google.com/maps?q=%2.6f,%2.6f&output=embed",
		newLocation.Latitude, newLocation.Longitude);
 
	FormatSettings.DecimalSeparator = lDecSeparator;
	WebBrowser1->Navigate(URLString);
宝龙哥 2015-04-20
  • 打赏
  • 举报
回复
先使用位置传感器取得当前的经度和纬度,如下: auto lDecSeparator = FormatSettings.DecimalSeparator; auto lSettings = FormatSettings; FormatSettings.DecimalSeparator = '.'; // Show current location ListBoxItemLatitude->ItemData->Detail = ListBoxItemLatitude->ItemData->Detail.sprintf(L"%2.6f", newLocation.Latitude); ListBoxItemLongitude->ItemData->Detail = ListBoxItemLongitude->ItemData->Detail.sprintf(L"%2.6f", newLocation.Longitude); 然后到谷歌或某个地图服务器,通过已知的经度和纬度查找到当前城市,所以一般的地图去位置信息的应用都有个上网取得大致位置的做法
宝龙哥 2015-04-20
  • 打赏
  • 举报
回复
引用 3 楼 Jonix 的回复:
[quote=引用 2 楼 kfrght 的回复:] 完整代码,因为不知道谷歌的这个位置服务是否被某某,所以你自己测试一下

	auto lDecSeparator = FormatSettings.DecimalSeparator;
	auto lSettings = FormatSettings;
	FormatSettings.DecimalSeparator = '.';

	ListBoxItemLatitude->ItemData->Detail =
		ListBoxItemLatitude->ItemData->Detail.sprintf(L"%2.6f", newLocation.Latitude);
	ListBoxItemLongitude->ItemData->Detail =
		ListBoxItemLongitude->ItemData->Detail.sprintf(L"%2.6f", newLocation.Longitude);

	auto lLongitude = FloatToStr(newLocation.Longitude, lSettings);
	String URLString = "";
	URLString = URLString.sprintf(L"https://maps.google.com/maps?q=%2.6f,%2.6f&output=embed",
		newLocation.Latitude, newLocation.Longitude);
 
	FormatSettings.DecimalSeparator = lDecSeparator;
	WebBrowser1->Navigate(URLString);
试了下,翻CB有点错,有C++版的吗?[/quote] 这个是BCB XE5版的,实测完全通过,你的出了什么错?
Jonix 2015-04-20
  • 打赏
  • 举报
回复
引用 2 楼 kfrght 的回复:
完整代码,因为不知道谷歌的这个位置服务是否被某某,所以你自己测试一下

	auto lDecSeparator = FormatSettings.DecimalSeparator;
	auto lSettings = FormatSettings;
	FormatSettings.DecimalSeparator = '.';

	ListBoxItemLatitude->ItemData->Detail =
		ListBoxItemLatitude->ItemData->Detail.sprintf(L"%2.6f", newLocation.Latitude);
	ListBoxItemLongitude->ItemData->Detail =
		ListBoxItemLongitude->ItemData->Detail.sprintf(L"%2.6f", newLocation.Longitude);

	auto lLongitude = FloatToStr(newLocation.Longitude, lSettings);
	String URLString = "";
	URLString = URLString.sprintf(L"https://maps.google.com/maps?q=%2.6f,%2.6f&output=embed",
		newLocation.Latitude, newLocation.Longitude);
 
	FormatSettings.DecimalSeparator = lDecSeparator;
	WebBrowser1->Navigate(URLString);
试了下,翻CB有点错,有C++版的吗?

551

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 茶馆
社区管理员
  • 茶馆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧