将NMAMapOverlay添加到地图 [英] Add an NMAMapOverlay to the Map

查看:100
本文介绍了将NMAMapOverlay添加到地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

This question was answered saying that NMAMapOverlay is the thing to use for a callout when a user taps a marker.

SDK文档说

NMAMapOverlay类代表一种特殊类型的地图对象, 不继承自NMAMapObject基类.相反,它 继承自Apple的UIKit框架的UIView类.

The NMAMapOverlay class represents a special type of map object that does not inherit from the NMAMapObject base class. Instead, it inherits from the UIView class of Apple’s UIKit framework.

因为它是UIView,所以不能调用NMAMapViewaddMapObject.

Since it is a UIView, you cannot call the addMapObject of NMAMapView.

我在文档中找不到如何向地图添加NMAMapOverlay的地方. SDKDemo应用程序中也不会使用NMAMapOverlay.

I cannot find anywhere in the documentation where it says how to add an NMAMapOverlay to the map. Nor is NMAMapOverlay used in the SDKDemo app.

所以我的问题是,如何将NMAMapOverlay添加到地图?

So my question is, how do you add an NMAMapOverlay to the Map?

推荐答案

使用以下代码,根据需要修改annotView.确保您已启用高级计划.它不适用于基本计划.

Use following code, Modify annotView as per your requirement. Make sure that you have premium plan enabled. It will not work with basic plan.

UIView *annotView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 20)];
annotView.backgroundColor = [UIColor redColor];
NMAMapOverlay *overlay = [[NMAMapOverlay alloc] initWithSubview:annotView];
overlay.coordinates = //your location's NMAGeoCoordinates
[self.mapView addMapOverlay:overlay];

这篇关于将NMAMapOverlay添加到地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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