{"action":"created","issue":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/1883","labels_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/1883/labels{/name}","comments_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/1883/comments","events_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/1883/events","html_url":"https://github.com/mapbox/mapbox-gl-native/issues/1883","id":94662666,"number":1883,"title":"PointAnnotations not showing","user":{"login":"hinken","id":3426061,"avatar_url":"https://avatars.githubusercontent.com/u/3426061?v=3","gravatar_id":"","url":"https://api.github.com/users/hinken","html_url":"https://github.com/hinken","followers_url":"https://api.github.com/users/hinken/followers","following_url":"https://api.github.com/users/hinken/following{/other_user}","gists_url":"https://api.github.com/users/hinken/gists{/gist_id}","starred_url":"https://api.github.com/users/hinken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hinken/subscriptions","organizations_url":"https://api.github.com/users/hinken/orgs","repos_url":"https://api.github.com/users/hinken/repos","events_url":"https://api.github.com/users/hinken/events{/privacy}","received_events_url":"https://api.github.com/users/hinken/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-07-13T08:06:21Z","updated_at":"2015-08-10T04:57:25Z","closed_at":null,"body":"I'm having problems with PointAnnotations not showing up\r\n\r\nThis code ends up not showing some of the markers\r\n```swift\r\nfunc mapView(mapView: MGLMapView, imageForAnnotation annotation: MGLAnnotation) -> MGLAnnotationImage? {\r\n        if let an = annotation as? TFPointAnnotation {\r\n            if var image = mapView.dequeueReusableAnnotationImageWithIdentifier(an.id) {\r\n                return image\r\n            } else {\r\n                if let title = an.title {\r\n                    return makeImage(title, reuseIdentifier: an.id)\r\n                } else {\r\n                    lg.debug(\"no title \\(an.id)\")\r\n                }\r\n            }\r\n        } else {\r\n            lg.debug(\"not a TFPoint\")\r\n        }\r\n        return nil\r\n    }\r\n    \r\n    func makeImage(title: String, reuseIdentifier: String) -> MGLAnnotationImage {\r\n        let rect = CGRectMake(0, 0, 50, 15);\r\n        UIGraphicsBeginImageContextWithOptions(rect.size, false, UIScreen.mainScreen().scale);\r\n        let ctx = UIGraphicsGetCurrentContext();\r\n        CGContextSetFillColorWithColor(ctx, UIColor.clearColor().CGColor);\r\n        CGContextFillRect(ctx, rect);\r\n        var attrs = [String : AnyObject]()\r\n        attrs[NSFontAttributeName] = UIFont(name: \"Arial-BoldMT\", size: 12)\r\n        attrs[NSForegroundColorAttributeName] = UIColor.blackColor()\r\n        \r\n        let drawString = NSAttributedString(string: title, attributes: attrs)\r\n        let stringSize = drawString.size();\r\n        let stringRect = CGRectMake((rect.size.width - stringSize.width) / 2,\r\n            (rect.size.height - stringSize.height) / 2,\r\n            stringSize.width,\r\n            stringSize.height);\r\n        drawString.drawInRect(stringRect)\r\n        \r\n        \r\n        let image = MGLAnnotationImage(image: UIGraphicsGetImageFromCurrentImageContext(), reuseIdentifier: reuseIdentifier)\r\n        UIGraphicsEndImageContext()\r\n        return image\r\n    }\r\n```\r\n![ios simulator screen shot 13 jul 2015 09 56 03](https://cloud.githubusercontent.com/assets/3426061/8645221/b4c6f96c-2945-11e5-9503-5b871da6f007.png)\r\n\r\nThis code shows markers on all positions but only using the same reuseidentifier\r\n```swift\r\nfunc mapView(mapView: MGLMapView, imageForAnnotation annotation: MGLAnnotation) -> MGLAnnotationImage? {\r\n        if let an = annotation as? TFPointAnnotation {\r\n            if var image = mapView.dequeueReusableAnnotationImageWithIdentifier(an.id) {\r\n                return image\r\n            } else {\r\n                if let title = an.title {\r\n                    return makeImage(\"bajs\", reuseIdentifier: \"bajs\")\r\n                } else {\r\n                    lg.debug(\"no title \\(an.id)\")\r\n                }\r\n            }\r\n        } else {\r\n            lg.debug(\"not a TFPoint\")\r\n        }\r\n        return nil\r\n    }\r\n    \r\n    func makeImage(title: String, reuseIdentifier: String) -> MGLAnnotationImage {\r\n        let rect = CGRectMake(0, 0, 50, 15);\r\n        UIGraphicsBeginImageContextWithOptions(rect.size, false, UIScreen.mainScreen().scale);\r\n        let ctx = UIGraphicsGetCurrentContext();\r\n        CGContextSetFillColorWithColor(ctx, UIColor.clearColor().CGColor);\r\n        CGContextFillRect(ctx, rect);\r\n        var attrs = [String : AnyObject]()\r\n        attrs[NSFontAttributeName] = UIFont(name: \"Arial-BoldMT\", size: 12)\r\n        attrs[NSForegroundColorAttributeName] = UIColor.blackColor()\r\n        \r\n        let drawString = NSAttributedString(string: title, attributes: attrs)\r\n        let stringSize = drawString.size();\r\n        let stringRect = CGRectMake((rect.size.width - stringSize.width) / 2,\r\n            (rect.size.height - stringSize.height) / 2,\r\n            stringSize.width,\r\n            stringSize.height);\r\n        drawString.drawInRect(stringRect)\r\n        \r\n        \r\n        let image = MGLAnnotationImage(image: UIGraphicsGetImageFromCurrentImageContext(), reuseIdentifier: reuseIdentifier)\r\n        UIGraphicsEndImageContext()\r\n        return image\r\n    }\r\n```\r\n\r\n![ios simulator screen shot 13 jul 2015 09 57 54](https://cloud.githubusercontent.com/assets/3426061/8645218/aef563ac-2945-11e5-80af-5aadef95e66e.png)\r\n\r\nWhy is this happening?"},"comment":{"url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/comments/129299846","html_url":"https://github.com/mapbox/mapbox-gl-native/issues/1883#issuecomment-129299846","issue_url":"https://api.github.com/repos/mapbox/mapbox-gl-native/issues/1883","id":129299846,"user":{"login":"ljbade","id":1215089,"avatar_url":"https://avatars.githubusercontent.com/u/1215089?v=3","gravatar_id":"","url":"https://api.github.com/users/ljbade","html_url":"https://github.com/ljbade","followers_url":"https://api.github.com/users/ljbade/followers","following_url":"https://api.github.com/users/ljbade/following{/other_user}","gists_url":"https://api.github.com/users/ljbade/gists{/gist_id}","starred_url":"https://api.github.com/users/ljbade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljbade/subscriptions","organizations_url":"https://api.github.com/users/ljbade/orgs","repos_url":"https://api.github.com/users/ljbade/repos","events_url":"https://api.github.com/users/ljbade/events{/privacy}","received_events_url":"https://api.github.com/users/ljbade/received_events","type":"User","site_admin":false},"created_at":"2015-08-10T04:57:25Z","updated_at":"2015-08-10T04:57:25Z","body":"@1ec5 Do you understand what is happening here and in #2019?"}}