Latest 1.0.0
Homepage https://github.com/jamesdouble/JDSwiftHeatMap
License MIT
Platforms ios 9.0
Authors

Alt text

JDSwiftMap is an IOS Native MapKit Library.

You can easily make a highly customized HeatMap.

Alt text
Alt text
Alt text
Alt text

Alt text

Installation

  • Cocoapods
    pod 'JDSWiftHeatMap'

Usage

JDSwiftHeatMap is based on IOS native MKMapView,

so you must familiar with.

Init

  • Give a frame.
  • Follow JDHeatMapDelegate.
  • Choose a MapType Below
  map = JDRealHeatMap(frame: self.view.frame, delegate: self, maptype: .FlatDistinct)
  self.view.addSubview(map!)

Delegate – Most Important

There are two delegate you need to pay close.

  1. MKMapViewDelegate – (Optional)

    This is the delegate you familiar,( AnnoationView For.., Render For…) You sure can use this delegate in old way, or not to follow this delegate.

    But if you do, you may need to follow two essential function.

    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

    When we talk to Heat Map, the most important thing is "Data" ! You should provide the data you want to display in this delegate.

    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
    }

    The default radius in km is 100KM.

Notice

More data will cause large memory using, should be notice.

Setting

  1. public func setType(type:JDMapType)

    change the display type, it will refresh automatically.

  2. public func refresh()

    Call this function when data changed.

  3. public var showindicator:Bool

    Set the loading indicator showing or not.

Latest podspec

{
    "name": "JDSwiftHeatMap",
    "version": "1.0.0",
    "summary": "You can easily make a highly customized HeatMap",
    "description": "JDSwiftMap is an IOS Native MapKit Library.nYou can easily make a highly customized HeatMap.",
    "homepage": "https://github.com/jamesdouble/JDSwiftHeatMap",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "JamesDouble": "jameskuo12345@gmail.com"
    },
    "source": {
        "git": "https://github.com/jamesdouble/JDSwiftHeatMap.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "JDRealHeatMap/JDSwiftHeatMap/*",
    "pushed_with_swift_version": "3.1"
}

Pin It on Pinterest

Share This