Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/181.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android:地图覆盖标签_Android - Fatal编程技术网

Android:地图覆盖标签

Android:地图覆盖标签,android,Android,我正在构建一个地图视图,我希望我的自定义覆盖项在用户点击它们时显示它们所标记位置的名称,就像Android地图应用程序一样 我将onTap侦听器和浮动文本视图设置为保存位置名称。我仍然需要对其进行设置,以便在用户移动地图时重新绘制标签,等等 不管怎样,我想知道我是否在重新发明轮子。有没有我不知道的内置方法?我认为MapView的大多数实现都有标签 作为参考,我目前的实施情况如下: 在地图xml中: <LinearLayout android:id="@+id/mapBubbleWrap"

我正在构建一个地图视图,我希望我的自定义覆盖项在用户点击它们时显示它们所标记位置的名称,就像Android地图应用程序一样

我将onTap侦听器和浮动文本视图设置为保存位置名称。我仍然需要对其进行设置,以便在用户移动地图时重新绘制标签,等等

不管怎样,我想知道我是否在重新发明轮子。有没有我不知道的内置方法?我认为MapView的大多数实现都有标签

作为参考,我目前的实施情况如下:

在地图xml中:

<LinearLayout android:id="@+id/mapBubbleWrap"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true">
    <TextView android:id="@+id/mapBubble" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:visibility="gone" 
        android:background="#ffffff" 
        android:textColor="#ff0000"/>
</LinearLayout>
在我的活动“聚焦”中:

public void onFocusChanged( ItemizedOverlay overlay, OverlayItem item ) {
    if( item != null) {
        mapBubble.setText(item.getTitle());
        Point newPoint = mapView.getProjection().toPixels(item.getPoint(), null);
        mapBubbleWrap.setPadding(newPoint.x, newPoint.y-10, 0, 0);
        mapBubble.setVisibility(View.VISIBLE);
    }
}
我认为这是最重要的 MapView的实现已经完成 标签

可能吧,但是除了你正在做的事情之外,谷歌地图插件中没有任何东西可以支持它们。虽然我并没有完全明白焦点是关于什么的。如果我想在用户点击时显示一个弹出面板,我只需要在用户点击时显示一个弹出面板——请参见示例

public void onFocusChanged( ItemizedOverlay overlay, OverlayItem item ) {
    if( item != null) {
        mapBubble.setText(item.getTitle());
        Point newPoint = mapView.getProjection().toPixels(item.getPoint(), null);
        mapBubbleWrap.setPadding(newPoint.x, newPoint.y-10, 0, 0);
        mapBubble.setVisibility(View.VISIBLE);
    }
}