如何在像 Uber 和 Lyft 这样的地图上附加一个灵活的标记? [英] How to attach a flexible marker on map something like Uber and Lyft?

查看:31
本文介绍了如何在像 Uber 和 Lyft 这样的地图上附加一个灵活的标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在像 Uber 和 Lyft 这样的地图上附加一个灵活的标记?我使用的是 Google 地图 v2.

How to attach a flexible marker on map something like Uber and Lyft ? am using Google maps v2.

基本上,我想在地图上显示一个标记,而移动地图时标记的位置会发生变化.

Basically, i want to display a marker on map while the position of the marker is changed upon moving the map.

好的,我解决了我的问题.

Ok i solved my problem.

first : 将一个图像视图添加到相同的布局和位置等于中心.第二:获取地图中心的坐标使用以下方法

first : add an imageview to the same layout and position equal to center. second: to get the coordinate of the center of the map use the following approach

1- 在我的地图片段所在的情况下获取视图组 ( FrameLayout ).

FrameLayout myContainer = (FrameLayout) findViewById(R.id.content_frame);
int mapHeight = myContainer.getHeight();
int mapWidth = myContainer.getWidth();

2- 使用 setOnCameraChangeListener 并在相机更改时获取坐标:

LatLng center = mMap.getCameraPosition().target;

推荐答案

好的,我解决了我的问题.

Ok i solved my problem.

first : 将一个图像视图添加到相同的布局和位置等于中心.第二:获取地图中心的坐标使用以下方法

first : add an imageview to the same layout and position equal to center. second: to get the coordinate of the center of the map use the following approach

1- 在我的地图片段所在的情况下获取视图组 ( FrameLayout ).

FrameLayout myContainer = (FrameLayout) findViewById(R.id.content_frame);
int mapHeight = myContainer.getHeight();
int mapWidth = myContainer.getWidth();

2- 使用 setOnCameraChangeListener 并在相机更改时获取坐标:

LatLng center = mMap.getCameraPosition().target;

这篇关于如何在像 Uber 和 Lyft 这样的地图上附加一个灵活的标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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