显示弹出上面的图形页面地图标记 [英] Show popup above map marker in MapView

查看:128
本文介绍了显示弹出上面的图形页面地图标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不敢相信有没有简单的方法做这样那样的一个基本的东西......我想显示弹出/气球(一的LinearLayout)用户点击地图上的标记之后(东西smilar什么是谷歌地图应用程序)。它应与地图移动,当用户滚动地图。什么是做到这一点的最好方法是什么?

I can't beleive there's no easy way to do such a basic thing like this... I want to show a popup/baloon (a LinearLayout) after user clicks on a map marker (something smilar to what is in Google Maps app). It should move with the map, when the user scrolls the map. What is the best way to do this?

一个想法是要有的LinearLayout在我活动的根布局并在需要时表现出来。但如何使之与地图移动?

One idea is to have the LinearLayout in my Activity's root layout and show it when needed. But how to make it move with the map?

另一种方式做到这一点可能会创建一个绘制的LinearLayout中的OnDraw并给出了布局触摸事件的叠加。这可能吗?

Another way to do that may be to create an Overlay that draws the LinearLayout in onDraw and gives the layout touch events. Is this possible?

推荐答案

我做的方法是:

把标记的要求GeoPoints通过继承ItemizedOverlay,如<一个描述href="http://developer.android.com/guide/tutorials/views/hello-mapview.html">http://developer.android.com/guide/tutorials/views/hello-mapview.html

Put the markers at required GeoPoints by subclassing ItemizedOverlay, as described in http://developer.android.com/guide/tutorials/views/hello-mapview.html

从布局膨胀创建一个弹出查看:

Create a popup View by inflating from the layout:

View popUp = getLayoutInflater().inflate(R.layout.map_popup, map, false);

使用MapView.LayoutParams相对于GeoPoint对象在ItemizedOverlay&LT定位弹出; OverlayItem> ::方法的onTap。弹出窗口会自动滚动(没有任何额外的code),当用户滚动地图。基本上弹出被拴在GeoPoint对象,如果用户缩放,弹出的位置被自动调整。

Use MapView.LayoutParams to position the popup with respect to GeoPoint in the ItemizedOverlay< OverlayItem >::onTap method. Popup will scroll automatically (without any additional code) when user scrolls the map. Basically popup gets tied to a GeoPoint, if user zooms, popup's position gets adjusted automatically.

MapView map = (MapView) findViewById(R.id.mapview);   
MapView.LayoutParams mapParams = new MapView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 
                        ViewGroup.LayoutParams.WRAP_CONTENT,
                        <geopoint>,
                        <x offset if required>,
                        <y offset like pinHeight>,
                        MapView.LayoutParams.BOTTOM_CENTER);
map.addView(popUp, mapParams);

这篇关于显示弹出上面的图形页面地图标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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