Fengmap iOS SDK

点标注 Fengmap iOS SDK 提供根据地图坐标点添加标注的功能。点标注可分为图片标注(ImageMarker)、文字标注(TextMarker)、定位标注(LocationMarker)等。

图片标注

使用图片标注功能用户可在指定坐标点位置添加自定义的图片标识。图片标注需要添加在图片标注层上。

• 创建图片标注层并添加到地图节点上。

// 初始化图片标注层,通过楼层id初始化。
FMKImageLayer *imageLayer = [[FMKImageLayer alloc] initWithGroupID:@"1"];
// 将图片标注层添加到地图上
 [_mapView.map addLayer: imageLayer];

• 创建图片标注并添加到图片标注层上

// 获取地图上某一点
FMKMapPoint point = FMKMapPointMake(x, y, z);
// 初始化图片标注
FMKImageMarker *imageMarker = [[FMKImageMarker alloc] initWithImage:
[UIImage imageNamed:@"blueImageMarker"] Coord:point];
// 设置图片标注大小
imageMarker.imageSize = CGSizeMake(30, 30);
// 设置图片标注位于地图上的位置
imageMarker.offsetMode = FMKImageMarker_MODELTOP;
// 添加图片标注物到图片标注层
[imageLayer addMarker:imageMarker];
文字标注

使用文字标注功能用户可在指定坐标点添加自定义文字内容。 文字标注需要添加在文字标注层上。

• 创建文字标注层并添加到地图节点上。

// 初始化文字标注层,通过楼层id初始化。
FMKTextLayer *textLayer = [[FMKTextLayer alloc] initWithGroupID:@"1"];
// 将文本标注层添加到地图上
[_mapView.map addLayer:textLayer];

• 创建文字标注并添加到文字标注层上。

// 获取地图上某一点
FMKMapPoint point = FMKMapPointMake(x ,y, 0);
// 初始化文本标注
FMKTextMarker *textMarker = [[FMKTextMarker alloc] initWithTextContent:@"这是一个文本标注" coord:point];
// 设置文本位于地图上的位置
textMarker.offsetMode = FMKTextMarker_MODELTOP;
textMarker.fontSize = 20;
textMarker.textColor = [UIColor redColor];
// 添加文本标注到文本标注层
[textLayer addMarker:textMarker];
定位标注

定位标注是用户可在指定坐标点位置添加的用于导航过程中展示位置的标识。地图的定位图层获取方式与模型图层的相类似,图层获取后可自行添加可定位的点,定位点可添加多个,同时定位点提供位置和方向变化的设置方法。

  • • 创建定位标注层并添加到地图节点上。
    // 获取定位标注层
    FMKLocationLayer *locationLayer = _mapView.map.locationLayer;
    // 添加定位标注点
    FMKLocationMarker *locateMarker = [[FMKLocationMarker alloc]
                      initWithPointerImageName:@"active.png" DomeImageName:@""];
    [locationLayer addMarker:locateMarker];
  • • 设置定位标注在地图中的位置和角度。
    FMKMapPoint point = FMKMapPointMake(x, y, 0);
    FMKGeoCoord coord = FMKGeoCoordMake(1, point);
    // 改变定位点位置
    [locateMarker locateWithGeoCoord:coord];
    // 改变定位点方向
    [locateMarker updateRotate:30];
动态模型标注

动态模型要素是用户在指定坐标点位置添加自定义的 3D 模型要素。3D 模型要素针对地图,一个地图可以添加多个模型要素,并且支持播放模型动画。

注:加载动态模型时,如果动态模型带有动画属性需要将地图渲染模式设置为主动渲染。

  • • 创建动态模型标注层并添加到地图上面。
    //设置地图渲染模式为主动渲染模式
    [_mapView setRealTimeRendering:YES];
    // 获取动态模型标注层
    FMKDynamicLayer *dynamicLayer = _mapView.map.dynamicLayer;
    // 添加动态模型标注点
    NSString *gltfPath= [[NSBundle mainBundle] pathForResource:@"fengniao" ofType:@"gltf"];
    FMKDynamicMarker *dynamicMarker = [[FMKDynamicMarker alloc] initWithPath:gltfPath];
    [dynamicLayer addMarker:dynamicMarker];
  • • 设置动态模型标注在地图中的位置。
    //设置动态模型位置
    [_dynamicMarker updatePosition:FMKGeoCoordMake(1, [_mapView getMapViewCenter])];
    //设置动态模型缩放比例,默认是1
    [_dynamicMarker scale:10];
    //更新动态模型标注水平旋转角
    [dynamicMarker rotate:105];
气泡窗标注

Fengmap iOS SDK 支持添加气泡窗口功能。气泡窗口为用户自定义View,可根据用户需求在地图上添加相应的视图。气泡窗口支持动态更新位置。

  • • 自定义View。
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 100, 30);
    [button setTitle:@"fengmap" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    FMKGeoCoord coord = FMKGeoCoordMake(1, FMKMapPointMake(x, y, 0);
  • • 初始化气泡窗。
    FMKBubbleView *bubbleView = [[FMKBubbleView alloc] initWithCustomView:button atPoint:coord];
  • • 将气泡窗口添加到地图上。
    [bubbleView addBubbleViewOnMapView:_mapView mapCoordZType:FMKMAPCOORDZ_EXTENT height:50];