JDSwiftHeatMap 2.0.0

JDSwiftHeatMap 2.0.0

测试测试
语言语言 SwiftSwift
许可证 MIT
发布上次发布2017年12月
SwiftSwift 版本3.1
SPM支持 SPM

JamesDouble 维护。



  • JamesDouble

Alt text

JDSwiftMap 是一个 IOS 本地 MapKit 库。

您可以轻松地制作高度定制的 HeatMap。

Alt text
Alt text
Alt text
Alt text

Alt text

安装

  • Cocoapods
	pod 'JDSWiftHeatMap'

使用方法

JDSwiftHeatMap 基于 IOS 本地 MKMapView

因此您必须熟悉。

初始化

  • 提供框架。
  • 遵循 JDHeatMapDelegate。
  • 选择以下地图类型
  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!)

基本颜色是元素颜色数组。

等级划分 = 基本颜色之间有多少中颜色。

委托 - 最重要

有两个委托您需要注意。

  1. 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
    
  2. 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。

注意

更多数据会导致 大量内存使用,应予以注意。

设置

  1. public func setType(type:JDMapType)

    更改显示类型,将自动刷新。

  2. public func refresh()

    数据更改时调用此函数。

  3. public var showindicator:Bool

    设置加载指示器显示或不显示。