java - 点击标记 en 去不同的活动
问题描述
对于我在学校的项目,我必须制作一个应用程序,让你在学校里游览。现在我想让我的地图上的标记可点击,并让它们使用 POI 的信息进行不同的活动。我知道 onMarkerListeners 和意图,但我不知道如何实现它。
public void onMapReady(GoogleMap googleMap) {
int height = 100;
int width = 100;
BitmapDrawable bitmapdraw=(BitmapDrawable)getResources().getDrawable(R.drawable.marker);
Bitmap b=bitmapdraw.getBitmap();
Bitmap smallMarker = Bitmap.createScaledBitmap(b, width, height, false);
mMap = googleMap;
mMap.setMyLocationEnabled(true);
mMap.getUiSettings().setMyLocationButtonEnabled(true);
LatLng HalA = new LatLng(50.8062795, 3.2922986);
LatLng stuvo = new LatLng(50.8061347, 3.2920485);
LatLng bib = new LatLng(50.8062763,3.2919120);
LatLng acco = new LatLng(50.8063492,3.2925983);
有更多的 POI,但这无关紧要。以下代码是我如何在地图上放置我的标记。
googleMap.addMarker(new MarkerOptions().position(HalA)
.title("Hal A")
.icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
googleMap.addMarker(new MarkerOptions().position(stuvo)
.title("Stuvo")
.icon(BitmapDescriptorFactory.fromBitmap(smallMarker)));
等等。我必须将我的 onMarkerListener 放在哪里?我必须将所有内容都放在 onCreate 中吗?我必须改变什么?
解决方案
推荐阅读
- javascript - 在 HTML 的多个表单中使用选定的选项
- java - 在对数组进行任何操作之前更新静态二维数组的大小
- algorithm - 逆适应(遗传算法)
- cypress - Cypress:如何防止测试运行程序在 cy.visit() 处重新加载?
- performance - Matlab - 使用 afterEach 进行并行文件搜索
- java - com.mysql.cj.jdbc.exceptions.CommunicationsException: 运行 jar 文件时通信链接失败
- python - 无法使用 Selenium 获取元素的文本
- c++ - for(int i=0,u,v; ...) 是什么意思?
- html - CSS 网格项设置图像的大小
- javascript - 如何将目录文件名存储在字符串数组中