通过意向通经/纬度 [英] Pass Latitude/longitude via intent

查看:120
本文介绍了通过意向通经/纬度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经收集不同的纬度和位置的经度。
我想知道如果我可以将它们作为数组的字符串,如(字符串纬度= {9385853.0094,23123123.234),然后通过意图通过他们,这样我可以拉/长在新型显示器使用谷歌地图的位置活动。

I have collected different latitude and longitude of locations. I want to know if i can set them as string of array for e.g(String lat = {"9385853.0094", "23123123.234")and then pass them via intent so that i can display the location in google map using lat/long in new activity.

推荐答案

例如,你有两个类叫做Maps.java和Routes.java。

For example you have two classes called Maps.java and Routes.java.

使用以下code传递经纬度

Use the following code to pass the LatLng

LatLng fromPosition = new LatLng(9385853.0094, 23123123.234 );
LatLng toPosition = new LatLng(11.145315551, 99.333455333);

Bundle args = new Bundle();
args.putParcelable("from_position", fromPosition);
args.putParcelable("to_position", toPosition);

i.putExtra("bundle", args);

Intent i= new Intent(Maps.this, Routes.class);
        startActivity(i);

和在接收端使用以下code

And at the receiving end use the following code

Bundle bundle = getIntent().getParcelableExtra("bundle");
LatLng fromPosition = bundle.getParcelable("from_position");
LatLng toPosition = bundle.getParcelable("to_position");

希望这有助于!

这篇关于通过意向通经/纬度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆