I am converting custom view load from xib into UIImage
to show as a marker icon.it is done but the problem is to when doing this in for loop to show 100 markers UI get stuck is it because of loading xib custom view?
below is the function calling in for loop
func generateSpot(Prop: Property) -> Spot {
let latStr = Prop.propLat
let langStr = Prop.propLang as NSString
let langDbl : Double = Double(langStr.floatValue)
let latDbl : Double = Double(latStr.floatValue)
let marker:GMSMarker = GMSMarker()
marker.position = CLLocationCoordinate2DMake(langDbl,latDbl)
marker.appearAnimation = kGMSMarkerAnimationPop
marker.title = Prop.propBuildingName as String
marker.snippet = Prop.propCode as String
marker.infoWindowAnchor = CGPointMake(0.44, 0.45)
let sizeVar:CGSize = CGSize(width: 41, height: 37)
let customeMarker :CustomMarker = NSBundle.mainBundle().loadNibNamed("CustomView", owner: self.view, options: nil).first! as! CustomMarker
customeMarker.frame = CGRectMake(customeMarker.frame.minX,customeMarker.frame.minY,customeMarker.frame.width,customeMarker.frame.height)
customeMarker.mappedNumbers.layer.masksToBounds = true
customeMarker.mappedNumbers.layer.cornerRadius = 8
customeMarker.mappedNumbers.text = Prop.propSequence as String
if Prop.propStatus == self.constants!.status.STATUS_COMPLETED_XML
{
customeMarker.mappedNumbers.backgroundColor = self.utility!.uicolorFromHex(0x70b420)
customeMarker.arrowImage.tintColor = self.utility!.uicolorFromHex(0x70b420)
}
if Prop.propStatus == self.constants!.status.STATUS_DRAFT_XML
{
customeMarker.mappedNumbers.backgroundColor = self.utility!.uicolorFromHex(0xd2cb46)
customeMarker.arrowImage.tintColor = self.utility!.uicolorFromHex(0x70b420)
}
if Prop.propStatus == self.constants!.status.STATUS_PENDING_XML
{
customeMarker.mappedNumbers.backgroundColor = self.utility!.uicolorFromHex(0xd44646)
customeMarker.arrowImage.tintColor = self.utility!.uicolorFromHex(0xd44646)
}
UIGraphicsBeginImageContextWithOptions(sizeVar, false, 0)
customeMarker.drawViewHierarchyInRect(customeMarker.bounds, afterScreenUpdates: true)
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
marker.icon = newImage
marker.map = self.googleMapView
let spotObje:Spot = Spot()
spotObje.location = marker.position
spotObje.marker = marker
return spotObje
}