将数据传递给 android 中的地图类

发布于 2024-11-02 13:02:06 字数 673 浏览 1 评论 0原文

因此,我正在与一个团队一起为我的学校开展一个项目,我们正在考虑实施一种方法来获得教职员工名单,并可以选择在 Android 上的校园地图上“映射他们”或他们的办公室。目前,我们的地图可以使用 itemizedOverlays 以及放大和缩小功能。

我的问题是,当使用此 Android 应用程序的人选择教职员工时,我如何将他们的信息(这只是他们的名字)传递给我们的地图类并将其与 itemizedOverlays 一起使用?

代码在这里: http://code.google.com/a/eclipselabs.org/p/mtsu-andriod/source/browse/trunk/%20mtsu- andriod%20--username%20craigmurphy88%40gmail.com/MTSU%20Android/src/com/MTSUAndroid/CampusMap.java

我们将把老师的名字从 person 类传递到maps 类。

So I'm working on a project for my School with a group and we're thinking about implementing a way to have a list of faculty and staff and have an option to "map them" or their office on a campus map on android. We have the map working currently with itemizedOverlays and zoom in and out features.

My question is when someone who uses this android app selects a faculty and staff member, how can I pass their information ( Which will just be their name ) to our maps class and use it with itemizedOverlays?

code is here:
http://code.google.com/a/eclipselabs.org/p/mtsu-andriod/source/browse/trunk/%20mtsu-andriod%20--username%20craigmurphy88%40gmail.com/MTSU%20Android/src/com/MTSUAndroid/CampusMap.java

we will be passing the teacher's name FROM the person class, TO the maps class.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鹊巢 2024-11-09 13:02:06

您还可以使用 Intent Extra 参数,如下所述:

http://developer.android .com/reference/android/content/Intent.html

private long lat, lng;
//.. onCreate
   lat = getIntent().getLongExtra("lat");
   lng = getIntent().getLongExtra("lon");

//...
GeoPoint office = new GeoPoint(lat, lng);
OverlayItem oi = new OverlayItem(office, "", "");
itemizedOverlay.addOverlay(oi);
//.. and so on.

在点击上,您可以像这样启动地图意图(“i”是您的地图意图,“t”是您的教师对象):

i.putExtra("lat", t.getPos().getLat());
i.putExtra("lng", t.getPos().getLng());

You could also use the Intent Extra parameters as described here:

http://developer.android.com/reference/android/content/Intent.html

private long lat, lng;
//.. onCreate
   lat = getIntent().getLongExtra("lat");
   lng = getIntent().getLongExtra("lon");

//...
GeoPoint office = new GeoPoint(lat, lng);
OverlayItem oi = new OverlayItem(office, "", "");
itemizedOverlay.addOverlay(oi);
//.. and so on.

On the Tap, you can launch your map intent like this ('i' is your map intent and 't' your Teacher Object):

i.putExtra("lat", t.getPos().getLat());
i.putExtra("lng", t.getPos().getLng());
那小子欠揍 2024-11-09 13:02:06

抱歉,我不明白你的意思。如果您希望在点击事件上显示特定的警报,您可以扩展 OverlayItem,以便它具有带有您的“人员 ID”或其他内容的额外参数。然后在覆盖层中的 onTap 方法上,获取与该 ID 对应的 Person(当然,在转换对象之后)。并相应地显示警报。

如果您想根据先前选择的元素显示覆盖(或一组覆盖项目),情况也是如此。通过将参数传递给 CampusMap 构造函数或(一种丑陋但更快的方法)将所选项目存储在静态类中并从 Map 访问它,这应该相当简单。

Sorry, I don't understand your point. If you want a particular alert to display on the tap event, you could extend OverlayItem in order for it to have an extra param with your "Person ID" or something. Then on the onTap method in the overlay, get the Person that corresponds to that ID (after casting your object, of course). And display the alert accordingly.

The same goes if you want to display an overlay (or a set of overlay items) according to the previously chosen element. This should be fairly simple by either passing a param to the CampusMap constructor or (an ugly approach but faster one) storing the chosen item in a static class and accessing it from the Map.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文