- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如标题所示,我尝试将自己的图像放在 map 上的注释中。为此,我使用此代码:
annotation.setImagePath (mImagePath);
annotation.setImageSize (4096);
annotation.setOffset (mSKScreenPoint));
没有错误,但什么也没有出现。
然而我遵循了文档的指示:
"Sets the absolute path of the image file to be added as an annotation.
The picture must be a square image and the size must be a power of 2.
_ (32x32, 64x64, etc.)."
我的图片大小是 64 * 64。
感谢这篇文章,我有了第一个迹象,但什么也没出现:
How do I set a custom image on an map annotation?
所以我将我的图像转换为 png-24 但仍然没有结果。 ((
最佳答案
在 2.1.0 中,我们添加了对使用资源包中的图像的支持并扩展了完整路径图像的示例 - 这是更新的 prepareAnnotations 代码:
更新:添加了 2.2.0 自定义 View 支持:
/**
* Draws annotations on map
*/
private void prepareAnnotations() {
// get the annotation object
SKAnnotation annotation1 = new SKAnnotation();
// set unique id used for rendering the annotation
annotation1.setUniqueID(10);
// set annotation location
annotation1.setLocation(new SKCoordinate(-122.4200, 37.7765));
// set minimum zoom level at which the annotation should be visible
annotation1.setMininumZoomLevel(5);
// set the annotation's type
annotation1.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_RED);
// render annotation on map
mapView.addAnnotation(annotation1, SKAnimationSettings.ANIMATION_NONE);
SKAnnotation annotation2 = new SKAnnotation();
annotation2.setUniqueID(11);
annotation2.setLocation(new SKCoordinate(-122.410338, 37.769193));
annotation2.setMininumZoomLevel(5);
annotation2.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_GREEN);
mapView.addAnnotation(annotation2, SKAnimationSettings.ANIMATION_NONE);
SKAnnotation annotation3 = new SKAnnotation();
annotation3.setUniqueID(12);
annotation3.setLocation(new SKCoordinate(-122.430337, 37.779776));
annotation3.setMininumZoomLevel(5);
annotation3.setAnnotationType(SKAnnotation.SK_ANNOTATION_TYPE_BLUE);
mapView.addAnnotation(annotation3, SKAnimationSettings.ANIMATION_NONE);
// add an annotation with an image file
SKAnnotation annotation = new SKAnnotation();
annotation.setUniqueID(13);
annotation.setLocation(new SKCoordinate(-122.434516, 37.770712));
annotation.setMininumZoomLevel(5);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
if (metrics.densityDpi < DisplayMetrics.DENSITY_HIGH) {
// set the center point of the image - tapping on an annotation will
// depend on
// this value . Also the actual gps coordinates of the annotation
// will
// be in the center of the image.
annotation.getOffset().setX(16);
annotation.getOffset().setY(16);
annotation.setImagePath(SKMaps.getInstance().getMapInitSettings().getMapResourcesPath()
+ "/.Common/poi_marker.png");
// set the size of the image in pixels
annotation.setImageSize(32);
} else {
// set the center point of the image - tapping on an annotation will
// depend on
// this value . Also the actual gps coordinates of the annotation
// will
// be in the center of the image.
annotation.getOffset().setX(32);
annotation.getOffset().setY(32);
annotation.setImagePath(SKMaps.getInstance().getMapInitSettings().getMapResourcesPath()
+ "/.Common/poi_marker_retina.png");
// set the size of the image in pixels
annotation.setImageSize(64);
}
mapView.addAnnotation(annotation, SKAnimationSettings.ANIMATION_NONE);
// add an annotation with a drawable resource
SKAnnotation annotationDrawable = new SKAnnotation();
annotationDrawable.setUniqueID(14);
annotationDrawable.setLocation(new SKCoordinate(-122.437182, 37.777079));
annotationDrawable.setMininumZoomLevel(5);
// set the center point of the image - tapping on an annotation will
// depend on
// this value . Also the actual gps coordinates of the annotation will
// be in the center of the image.
annotationDrawable.setOffset(new SKScreenPoint(64, 64));
SKAnnotationView annotationView = new SKAnnotationView();
annotationView.setDrawableResourceId(R.drawable.icon_map_popup_navigate);
// set the width and height of the image in pixels (they have to be
// powers of 2)
annotationView.setWidth(128);
annotationView.setHeight(128);
annotationDrawable.setAnnotationView(annotationView);
mapView.addAnnotation(annotationDrawable, SKAnimationSettings.ANIMATION_NONE);
// // add an annotation with a view
SKAnnotation annotationFromView = new SKAnnotation();
annotationFromView.setUniqueID(15);
annotationFromView.setLocation(new SKCoordinate(-122.423573, 37.761349));
annotationFromView.setMininumZoomLevel(5);
annotationView = new SKAnnotationView();
// set view object to be displayed as annotation
annotationView.setView(customView);
annotationFromView.setAnnotationView(annotationView);
mapView.addAnnotation(annotationFromView, SKAnimationSettings.ANIMATION_NONE);
selectedAnnotation = annotation1;
// set map zoom level
mapView.setZoom(13);
// center map on a position
mapView.centerMapOnPosition(new SKCoordinate(-122.4200, 37.7765));
}
关于android - Skobbler Android - 如何在 map 上的注释中设置自定义图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24304249/
我想在转弯导航期间从 SKNavigationState 导航期间找到环岛的导出编号(例如第二个导出)。 我查看了文档,但找不到通过 Android SDK 找到它的方法。 我试过了 SKNaviga
我正在为我的 Android 应用程序使用 skmaps。路线被计算并绘制在 map 上,当导航开始时,蓝色圆圈箭头没有随着路线移动(屏幕不跟随光标)很快就看不见了。用户必须不断调整屏幕才能再次看到箭
导航开始后,用户可以选择在屏幕之间切换。有两个屏幕有两个不同的 map - 一个显示导航,另一个显示一些 POI。 每当屏幕发生变化时,都会设置新的代理并将 [SKRoutingService sha
初始化 map 后,我在某个坐标上添加了一个注释 func initMap(){ SKRoutingService.sharedInstance().navigationDelegate =
我需要获取用户当前导航的高速公路名称。这可以在导航模式下完成,从 -(void)routingService:(SKRoutingService *)routingService didChangeC
我一直在玩 Skobbler SDK演示应用程序。我对 SKRouteAdvice 特别感兴趣,它基本上建议您向左转等等。 我在 Swift 演示中遇到的问题是,它似乎在旅行开始之前就为您提供了整套建
我在任何级别的样式编辑器中都找不到任何“徽章”功能,我想更改道路徽章的颜色。 最佳答案 map 上的徽章图标与所使用的徽章图像之间的链接位于 .json 文件中。 所有徽章图标均在“Common”文件
我在 iOS 9/iPhone 6 上运行的 native iOS 应用程序中使用 Skobbler iOS SDK (2.5.1)。 在 Beta 测试人员的设备上,在导航的某个点,C++ 代码深处
我正在使用 skobbler 构建一个离线驾车游览应用程序。在应用程序中,有一条自定义路线供用户遵循。我可以使用 SKPolyline 类绘制折线,但如果有一种方法可以直接在折线上指示方向,那就更好了
我正在使用 SKRouteManager 计算路线,如下所示: route.setStartCoordinate(origCoords); route.setDestinationCoordinate
我在 ios 应用程序中使用 skmaps,在这个应用程序中我必须离线使用城市 map ,所以我必须下载用户选择的 map 。我已经实现了示例中的代码: #import "MapJSONViewCon
我正在创建一个 Skobbler 注释,如下所示: markerCoords = mapView.pointToCoordinate(skScreenPoint); //gives us the co
我已经使用 Skobbler SDK 创建了一张 map 并添加了一些注释,但是当我触摸一个注释时,以下方法不会启动: func mapView(mapView:SKMapView!, didSele
我必须修改 SKAnnotation 的图像。注释生成器代码: private SKAnnotation getAnnotationFromView (int id,int minZoomLvl, V
我有以下用于在指定位置打开 Skobbler 的代码: - (void)openSkobblerWithLatitude:(double)latitude longitude:(double)long
在 iOS 中使用 Skobbler map 时出现异常。似乎是导致无效数组访问的并发异常,但由于 Skobbler 提供的代码存在问题,因此不确定如何以最佳方式修复其损坏的代码。 请参阅标记为“HE
我正在为 iOS 应用程序使用 Skobbler map 。是否可以为 POI 类别设置优先级,以便当多个 POI 分组时,该类别的图标位于最前面? 因此,如果信息图标具有更高的优先级,则它应该显示在
我正在为我的 map 项目使用 Skobbler。我想允许用户下载部分 map 以供离线使用。正如我从文档中了解到的那样,我们可以使用该地区的 offlinePackageCode 下载城市、州或国家
我想弄清楚如何将 pin 聚类与 SKMapView 和 SKAnnotation 一起使用?我看到有 SKPOICluster,但我不确定是否有办法将它与 SKAnnotation 一起使用。 最佳
我在尝试计算路线时遇到了这个奇怪的错误。它只发生在第一次应用打开时。在我关闭一个应用程序并重新启动它后,它会按预期运行,并执行完全相同的操作。 我得到 Route calculation failed
我是一名优秀的程序员,十分优秀!