在Android MapBox GL中构建自定义叠加层,具体是带有半径(彩色)的圆 [英] Building custom overlay specifically circle with radius(colored) in Android MapBox GL

查看:218
本文介绍了在Android MapBox GL中构建自定义叠加层,具体是带有半径(彩色)的圆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android MapBox GL中构建自定义叠加层,特别是半径(彩色)的圆形.它允许使用搜索栏动态更改半径.

Building custom overlay specifically circle with radius(colored) in Android MapBox GL. It allows to change radius dynamically using seekbar.

我正在尝试构建一些自定义标记,并且我使用了

I'm trying to build some custom markers and I used SimpleCircleView but Im having problem trying to display it in MapBox GL android, and it created lots of bugs.

  1. 我的CircleOverlay显示在地图中后,地图触摸事件无响应
  2. 一旦放大,缩小,标记就不会停留在其坐标中.
  3. 更新标记无效,因此我必须删除然后再次添加标记.
  4. 颜色与我在标记中设置的颜色不匹配.
  1. The map touch event is unresponsive once my CircleOverlay is displayed in map
  2. The marker doesnt stay in its coordinates once i zoom-in , zoom-out.
  3. Updating markers doesnt work, So I have to remove then add again the marker.
  4. The color does not match the color that I set in marker.

我将限制在代码上的发布,因为此回购是我的,并且可以使问题易于理解.

I'll limit my posting on code, because this repo is mine and to keep the problem understandable.

在构建自定义叠加层时,我必须创建以下类:

In building custom overlay I have to make these classes:

  1. CircleMarkerView .java -自定义标记视图
  2. [CircleMarkerViewOptions.java]( https://github.com/spurdow/SimpleCircleView/blob/master/app/src/main/java/com/spurdow/circleviewtest/CircleMarkerViewOptions.java )-与CircleMarkerView
  3. SimpleCircleView .java -这是我的自定义视图,用于更改半径等的动态圆.
  4. MainActivityMapBox -这是放置所有内容的地方
  1. CircleMarkerView.java - The Custom Marker View
  2. [CircleMarkerViewOptions.java] (https://github.com/spurdow/SimpleCircleView/blob/master/app/src/main/java/com/spurdow/circleviewtest/CircleMarkerViewOptions.java) - This is to be used with CircleMarkerView
  3. SimpleCircleView.java - This is my custom view for dynamic circle changing its radius etc.
  4. MainActivityMapBox - This is where to put it all

这是仓库中代码的示例.

This is an example of the code in the repo.

有人知道如何简单地做到这一点吗? 或者 还有另一种动态构建覆盖图的方法吗? 或者 当seekbar的进度更改时,是否可以动态创建圆形位图并将其转换为图标?

Does anybody have any idea how to do this simply? Or Is there another way of building an overlay dynamically? Or Is it possible to create a circle bitmap dynamically and convert it to icon when seekbar's progress is changing?

推荐答案

1.我的CircleOverlay显示在地图中后,地图触摸事件将不响应
这是我们计划在下一个版本中解决的问题,您可以在此此处关注进度.

1. The map touch event is unresponsive once my CircleOverlay is displayed in map
This is an issue we plan to address by next release, you can follow progress on this here.

2.一旦放大,缩小,标记就不会停留在其坐标中.
可能是因为您没有使用.setAnchor()正确锚定标记图标,或者图标周围有填充.对于圆,您将希望锚定居中(使用0.5f).在先前的稳定版本之前引入了一个错误,该错误会导致无法正常工作.如果这是一个问题,请使用4.2.0-SNAPSHOT.

2. The marker doesnt stay in its coordinates once i zoom-in , zoom-out.
The could be because you aren't anchoring the marker icon correctly using .setAnchor() or your icon has padding around it. For a circle, you'll want to anchor centered (using 0.5f). A bug was introduced right before the previous stable release that causes anchoring not to work correctly. If this is an issue, use the 4.2.0-SNAPSHOT.

3.更新标记无效,因此,我必须先删除然后再添加标记. 您能详细说明这个问题吗?您可能正在使用

3. Updating markers doesnt work, So I have to remove then add again the marker. Could you elaborate on this issue? You might be using

Marker marker = mapboxMap.addMarker(new MarkerViewOptions()...

何时应使用:

MarkerView marker = mapboxMap.addMarker(new MarkerViewOptions()...

这将为您提供更多选择来更新标记.

Which will give you more options to update markers.

4.颜色与我在标记中设置的颜色不匹配.
您能说明一下这是什么意思吗?

4. The color does not match the color that I set in marker.
Could you clarify what you mean by this?

这听起来像是您想要执行

It sounds like you are wanting to do what this example does in the testapp? I would follow along with the code found there.

这篇关于在Android MapBox GL中构建自定义叠加层,具体是带有半径(彩色)的圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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