Manos Chorianopoulos

add custom pins at MapsViewController

......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -440,6 +440,58 @@ import MapKit
//
// return annotationView
// }
// map view delegate
public func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
// guard !(annotation is MKUserLocation) else {
// return nil
// }
var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "warply_custom")
if (annotationView == nil) {
annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "warply_custom")
annotationView?.canShowCallout = false
} else {
annotationView?.annotation = annotation
}
// Add custom pin image
annotationView?.frame = CGRect(x: 0, y: 0, width: 45, height: 60)
let pinImageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 45, height: 60))
pinImageView.contentMode = .scaleAspectFit
if let pinImg = UIImage(named: "map_pin", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) {
pinImageView.image = pinImg
}
let logoImageView = UIImageView(frame: CGRect(x: 5, y: 5, width: 35, height: 35))
logoImageView.contentMode = .scaleAspectFit
let merchant = annotation as? MerchantAnnotation
if let merchantModel = merchant?.model {
let currentMerchant = merchantModel
if let parent = self.parentMerchantsArray.first(where: {($0._uuid == currentMerchant._parent)}) {
let currentMerchantParent = parent
if (self.isMarket == true) {
logoImageView.load(link: currentMerchantParent._img_preview , placeholder: UIImage(), cache: URLCache())
} else {
logoImageView.load(link: currentMerchant._img_preview , placeholder: UIImage(), cache: URLCache())
}
}
}
pinImageView.addSubview(logoImageView)
annotationView?.addSubview(pinImageView)
return annotationView
}
public func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
let merchant = view.annotation as? MerchantAnnotation
......
{
"images" : [
{
"filename" : "map_pin.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "map_pin 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "map_pin 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}