- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
这是我想要实现的东西的截图
我想为 map 的每个覆盖项添加唯一标签(如数字)。我已经完成了添加叠加项并在 map 上显示它们的基本部分。但是这个我卡了很久的地方
最佳答案
您可以使用函数在同一 ItemizedOverlay
上添加具有不同标记的 OverlayItem
:
overlayItem.setMarker(drawable);
为此,您需要在 Drawable
上设置边界:
Drawable icon1 = getResources().getDrawable(R.drawable.icon1);
Drawable icon2 = getResources().getDrawable(R.drawable.icon2);
icon1.setBounds(0, 0, icon1.getIntrinsicWidth(), icon1.getIntrinsicHeight());
icon2.setBounds(0, 0, icon2.getIntrinsicWidth(), icon2.getIntrinsicHeight());
OverlayItem item1 = new OverlayItem(new Point(48858290, 2294450),
"Tour Eiffel", "La tour Eiffel");
OverlayItem item2 = new OverlayItem(new Point(48873830, 2294800),
"Arc de Triomphe", "L'arc de triomphe");
item1.setMarker(icon1);
item2.setMarker(icon2);
您将需要与最大标记数一样多的位图。但它比在位图上动态绘制文本要快。这是一部手机,处理器速度不快。如果你更喜欢在 Bitmap 上绘制文本,其实很简单,你可以这样做:
//get a reference on the ImageView
ImageView iv = (ImageView)findViewById(R.id.myImage);
// load the marker image
Bitmap myRefBitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.icon);
// create a mutable bitmap with the same size as the marker image
Bitmap myWrittenBitmap = Bitmap.createBitmap(myRefBitmap.getWidth(),
myRefBitmap.getHeight(), Bitmap.Config.ARGB_4444);
// create a Canvas on which to draw and a Paint to write text.
Canvas canvas = new Canvas(myWrittenBitmap);
Paint txtPaint = new Paint();
txtPaint.setColor(Color.RED);
txtPaint.setTextSize(12);
txtPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
txtPaint.setTypeface(Typeface.DEFAULT_BOLD);
//draw ref bitmap then text on our canvas
canvas.drawBitmap(myRefBitmap, 0, 0, null);
canvas.drawText("Droid", 5, 15, txtPaint);
// set the new written bitmap into the ImageView
iv.setImageBitmap(myWrittenBitmap);
关于android - 如何在android中的mapview的overlayitem上绘制独特的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5216228/
那是我的代码: OverlayItem overlayItem = new OverlayItem(point, "Test", "Hello"); itemizedOverlay.addOverla
我希望能够获得一些对正在绘制的当前对象的引用 @Override public void draw(Canvas canvas, MapView mapView,boolean sha
我正在使用 OSMdroid。 感谢这篇文章,我成功了 Adding Overlay to OSMDROID在特定位置创建叠加静态项目。 现在我正在尝试使 map 更加动态。因此,当位置发生变化时,O
我必须在特定点的 map 上放置一些叠加层,我从 API 获取点坐标。我在异步任务中进行抓取。我成功地放置了叠加层,当我放大 map 或跨越它时,响应非常慢。这是我的 overlayitem 类和我的
我想在我的 map 上显示不同的标记。我能找到的一种解决方案是为每个标记定义一个新的叠加层。但后来我发现用 可以更容易地完成 OverlayItme.set Marker(Drawable marke
我有一个简单的 Google map 叠加层:http://pastebin.com/Rg8miMSh我根据缩放级别在其上添加/删除项目。删除/添加后,我在叠加层上调用 populate 并在 map
我正在用单个 ItemizedOverlay 中的几十个 OverlayItem 构建 map 。我的 map 可以非常近地查看(大约 18+ 缩放级别),OverlayItems 彼此非常接近。放大
我创建了一个自定义的 OverlayItem 类,这样我基本上可以拥有一种 OverlayItem,其 Drawable 标记会根据我传递给它的某些数据的状态自行设置。 我试图通过在我的第一次尝试中使
我有一个类,它扩展了 OverlayItem 以包含更多字段。我已经使用 PointOfInterest 类更改了程序中出现的所有 OverlayItem。 当我尝试运行适用于 OverlayItem
如何从 OverlayItem 打开 Activity:现在这是我的代码: @Override protected boolean onBalloonTap(int index) { if (
我在获取某个 OverlayItem 正在使用的可绘制对象时遇到了一些麻烦,因此我可以计算它的高度并正确偏移显示 onTap 的注释。这是我尝试获取该可绘制对象的代码: Drawable marker
我有一个使用 mapview-overlay-manager 的应用程序使用 Web API 中的 LazyLoadManager 在 MapView 上绘制 map 标记的代码。当我拖动 map 时
我正在开发 android 应用程序,我能够使用 ItemizedOverlay 在 map 上显示多个图标,我还实现了 ItemizedOverlay 的 onTap(int index) 方法以在
我有一个可用的 MapView,上面有 Overlays。我已经完成了官方 MapView-Tutorial:http://developer.android.com/guide/tutorials/
我正在开发 MapView 应用程序,并想在程序中放置一个漂亮的小复活节彩蛋。我想要做的是有一个基本上不可见的叠加项,但是当点击时会触发一个事件来显示 View 。 现在在 iPhone 上,我通过在
我在使用 Android MapView API 时遇到了一些问题。我从要在 MapView 中显示的数据库中获取 OverlayItems。如果我显示 100 个图标,我没有问题,但如果它变得更多—
首先,我在这里继承了很多代码,虽然我已经梳理了几次以寻找这种行为的原因,但我很困惑。 我希望最后点击的 OverlayItem 位于其余部分之上,即使它看起来很傻。我看到的是,虽然 MapView 正
在我的应用中有一个MapView,我给它添加了OverlayItems,大约500个,但以后会更多甚至数千个... 我的问题是:当我切换到此 Activity 时,我遇到了 3-4 秒的大量停电,然后
我有一个 map View ,其中在不同的地址上绘制了多个图钉。一切都很好。当您有多个项目指向同一个地址时,就会出现问题。例如, 单元 1/45 ABC 街,XYZ XYZ ABC 街 45 号单元
我想进一步注释我放置在 MapView 上的自定义标记(使用 ItemizedOverlay),方法是显示一个简单的文本标签,该标签在触发 onTap 事件时针对特定项目显示。 这是 Google M
我是一名优秀的程序员,十分优秀!