Giter VIP home page Giter VIP logo

jdswiftheatmap's Introduction

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!)

With ColorSetting

  map = JDSwiftHeatMap(frame: mapsView.frame, delegate: self, maptype: .FlatDistinct, BasicColors: [UIColor.yellow,UIColor.red], devideLevel: 2)
  self.view.addSubview(map!)

BasicColors is element color array.

Devide Level = How Many Middle Colors between Basic Colors.

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.

jdswiftheatmap's People

Contributors

jamesdouble avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.