diff --git a/JDRealHeatMap.xcodeproj/project.xcworkspace/xcuserdata/JamesDouble.xcuserdatad/UserInterfaceState.xcuserstate b/JDRealHeatMap.xcodeproj/project.xcworkspace/xcuserdata/JamesDouble.xcuserdatad/UserInterfaceState.xcuserstate index 6b8bfe6..f08815f 100644 Binary files a/JDRealHeatMap.xcodeproj/project.xcworkspace/xcuserdata/JamesDouble.xcuserdatad/UserInterfaceState.xcuserstate and b/JDRealHeatMap.xcodeproj/project.xcworkspace/xcuserdata/JamesDouble.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/JDRealHeatMap/JDSwiftHeatMap/JDRealHeatMap.swift b/JDRealHeatMap/JDSwiftHeatMap/JDRealHeatMap.swift index ecc0be8..31adce1 100644 --- a/JDRealHeatMap/JDSwiftHeatMap/JDRealHeatMap.swift +++ b/JDRealHeatMap/JDSwiftHeatMap/JDRealHeatMap.swift @@ -29,7 +29,7 @@ public class JDSwiftHeatMap:MKMapView var missionController:JDHeatMapMissionController! var indicator:UIActivityIndicatorView? // - var showindicator:Bool = true{ + public var showindicator:Bool = true{ didSet{ if(!showindicator) { @@ -67,6 +67,10 @@ public class JDSwiftHeatMap:MKMapView public func refresh() { + if(self.showindicator) + { + self.indicator?.startAnimating() + } missionController.ExecuteRefreshMission() } @@ -97,14 +101,16 @@ public class JDSwiftHeatMap:MKMapView indicator = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge) indicator?.translatesAutoresizingMaskIntoConstraints = false self.addSubview(indicator!) - let sizeWidth = NSLayoutConstraint(item: indicator!, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 0.0, constant: 100) - let sizeHeight = NSLayoutConstraint(item: indicator!, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 0.0, constant: 100) - let rightCon = NSLayoutConstraint(item: indicator!, attribute: .trailing, relatedBy: .equal, toItem: self, attribute: .trailing, multiplier: 1.0, constant: 0) - let BottomCon = NSLayoutConstraint(item: indicator!, attribute: .bottom, relatedBy: .equal, toItem: self, attribute: .bottom, multiplier: 1.0, constant: 0) + let sizeWidth = NSLayoutConstraint(item: indicator!, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 0.0, constant: 60) + let sizeHeight = NSLayoutConstraint(item: indicator!, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 0.0, constant: 60) + let CenterX = NSLayoutConstraint(item: indicator!, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1.0, constant: 0) + let CenterY = NSLayoutConstraint(item: indicator!, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1.0, constant: 0) + + //let rightCon = NSLayoutConstraint(item: indicator!, attribute: .trailing, relatedBy: .equal, toItem: self, attribute: .trailing, multiplier: 1.0, constant: 0) + //let BottomCon = NSLayoutConstraint(item: indicator!, attribute: .bottom, relatedBy: .equal, toItem: self, attribute: .bottom, multiplier: 1.0, constant: 0) indicator?.addConstraints([sizeWidth,sizeHeight]) - self.addConstraints([rightCon,BottomCon]) + self.addConstraints([CenterX,CenterY]) self.updateConstraints() - indicator?.startAnimating() } } diff --git a/JDRealHeatMap/ViewController.swift b/JDRealHeatMap/ViewController.swift index 772e3ff..db9141b 100644 --- a/JDRealHeatMap/ViewController.swift +++ b/JDRealHeatMap/ViewController.swift @@ -20,7 +20,7 @@ class ViewController: UIViewController { super.viewDidLoad() addRandomData() - map = JDSwiftHeatMap(frame: mapsView.frame, delegate: self, maptype: .FlatDistinct) + map = JDSwiftHeatMap(frame: mapsView.frame, delegate: self, maptype: .RadiusDistinct) map?.delegate = self mapsView.addSubview(map!) } diff --git a/README.md b/README.md index f0d0ec0..85a7ab8 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,11 @@ You can easily make a highly customized HeatMap. ![Alt text](https://raw.githubusercontent.com/jamesdouble/JDSwiftHeatMap/master/Readme_img/jdheatmapDemo.png?token=AJBUU1UA_L_wx5f_E3iRsaUGAh_xg3pCks5Zb1yIwA%3D%3D) # Installation +* Cocoapods +``` + pod 'JDSWiftHeatMap' +``` # Usage @@ -82,10 +86,22 @@ There are two delegate you need to pay close. ``` *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.