测试测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布上次发布 | 2017年12月 |
SwiftSwift 版本 | 3.1 |
SPM支持 SPM | ✗ |
由 JamesDouble 维护。
JDSwiftMap 是一个 IOS 本地 MapKit 库。
您可以轻松地制作高度定制的 HeatMap。
pod 'JDSWiftHeatMap'
JDSwiftHeatMap 基于 IOS 本地 MKMapView,
因此您必须熟悉。
map = JDRealHeatMap(frame: self.view.frame, delegate: self, maptype: .FlatDistinct)
self.view.addSubview(map!)
map = JDSwiftHeatMap(frame: mapsView.frame, delegate: self, maptype: .FlatDistinct, BasicColors: [UIColor.yellow,UIColor.red], devideLevel: 2)
self.view.addSubview(map!)
基本颜色是元素颜色数组。
等级划分 = 基本颜色之间有多少中颜色。
有两个委托您需要注意。
MKMapViewDelegate - (可选)
这是您熟悉的委托( annotationView For.., render For...),您当然可以使用这个委托以旧方式使用,或者不遵循这个委托。
但如果您确实这样做,您可能需要遵循两个基本函数。
extension ViewController:MKMapViewDelegate
{
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer
{
if let heatoverlay = map?.heatmapView(mapView, rendererFor: overlay)
{
return heatoverlay
}
else
{
var yourownRender = yourownRenderClass()
return yourownRender
}
}
func mapViewWillStartRenderingMap(_ mapView: MKMapView)
{
map?.heatmapViewWillStartRenderingMap(mapView)
}
}
map.delegate = self
JDHeatMapDelegate
当我们谈论 Heat Map 时,最重要的东西是 "数据"!您应该在此委托中提供您想要显示的数据。
public protocol JDHeatMapDelegate {
func heatmap(HeatPointCount heatmap:JDRealHeatMap) -> Int
func heatmap(HeatLevelFor index:Int) -> Int
@Optional func heatmap(RadiusInKMFor index:Int) -> Double
func heatmap(CoordinateFor index:Int) -> CLLocationCoordinate2D
}
默认半径为100KM。
更多数据会导致 大量内存使用,应予以注意。
public func setType(type:JDMapType)
更改显示类型,将自动刷新。
public func refresh()
数据更改时调用此函数。
public var showindicator:Bool
设置加载指示器显示或不显示。