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

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

问题描述

如何将附加在地图上像尤伯杯和Lyft一个灵活的标示? 现在用谷歌地图V2。

基本上,我想在地图上显示一个标记,而标记的位置是在移动地图改变。

编辑:

好吧,我解决我的问题。

第一:一个ImageView的添加到相同的布局和位置为中心。 第二:拿到地图的中心坐标使用下面的方法

  1_得到的ViewGroup(的FrameLayout)在我的情况下,地图片段的位置。

      - 的FrameLayout myContainer中=(的FrameLayout)findViewById(R.id.content_frame);
        INT mapHeight = myContainer.getHeight();
        INT mapWidth = myContainer.getWidth();
    2_使用setOnCameraChangeListener和摄像头的变化得到的坐标:

经纬度中心= mMap.getCameraPosition()的目标。
 

解决方案

编辑:

好吧,我解决我的问题。

第一:一个ImageView的添加到相同的布局和位置为中心。第二:拿到地图的中心坐标使用下面的方法

  1_得到的ViewGroup(的FrameLayout)在我的情况下,地图片段的位置。

  - 的FrameLayout myContainer中=(的FrameLayout)findViewById(R.id.content_frame);
    INT mapHeight = myContainer.getHeight();
    INT mapWidth = myContainer.getWidth();
2_使用setOnCameraChangeListener和摄像头的变化得到的坐标:

经纬度中心= mMap.getCameraPosition()的目标。
 

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.

edited:

Ok i solved my problem.

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_ get viewgroup ( FrameLayout ) in my case where the map fragment is located.

     - FrameLayout myContainer = (FrameLayout) findViewById(R.id.content_frame);
        int mapHeight = myContainer.getHeight();
        int mapWidth = myContainer.getWidth();
    2_ use setOnCameraChangeListener and on camera change get the coordinates:

LatLng center = mMap.getCameraPosition().target;

解决方案

edited:

Ok i solved my problem.

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_ get viewgroup ( FrameLayout ) in my case where the map fragment is located.

 - FrameLayout myContainer = (FrameLayout) findViewById(R.id.content_frame);
    int mapHeight = myContainer.getHeight();
    int mapWidth = myContainer.getWidth();
2_ use setOnCameraChangeListener and on camera change get the coordinates:

LatLng center = mMap.getCameraPosition().target;

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

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