objective c - Custom Marker performance iOS, crash with result "((null)) was false: Reached the max number of texture atlases, can not allocate more." -


i have integrated google maps in application , using google places api. after getting results google places api(around 60), displaying them of custom marker. custom marker making comprises of "place image" , "place name" because of have first draw in uiview , render uiimage of following function

- (uiimage *)imagefromview:(uiview *) view {     if ([[uiscreen mainscreen] respondstoselector:@selector(scale)]) {          uigraphicsbeginimagecontextwithoptions(view.frame.size, no, [[uiscreen mainscreen] scale]);     } else {         uigraphicsbeginimagecontext(view.frame.size);     }     [view.layer renderincontext: uigraphicsgetcurrentcontext()];     uiimage *image = uigraphicsgetimagefromcurrentimagecontext();     uigraphicsendimagecontext();      return image; } 

at first markers rendered , drawn easily.

now have slider ranging 100m 5km, acts search radius optimiser. slider moved(suppose value 2km), markers removed , markers distance user location less slider value drawn again. while testing slider functionality, application crashes saying

((null)) false: reached max number of texture atlases, can not allocate more.

i uploading screen shots clear understanding of situation. please help.

image when radius 5km

image when radius 2.4km

image when radius 1.7km

also mention, in screens see green markers blue markers. blue markers closer user location while green ones far off particular distance. user location change there 2 cases:

  1. if approaching green marker, turn blue marker
  2. if going far blue marker, turn green marker.

i working on app can have several thousand avatars moving around on map , encounter bug also. clustering potential solution, many avatars moving, suspect calculations cpu intensive.

the solution use keep reference base avatar image , use when > 50 avatars on screen. when there < 50 avatars on screen, generate unique images each avatars names.

// gmsmarker static var avatardic:[string:uiimage] = dictionary()  func removename() {     // use single image reference here google map not crash     if let image = avatardic[avatarbase] {         self.icon = image     }     else {         avatardic[avatarbase] = uiimage(named:avatarbase)         self.icon = avatardic[avatarbase]     } }  func addname() {     self.icon = // draw name on base image }  // gmsmapview var usericons:[string:mymarker] = dictionary() var iconwithnames:set<mymarker> = set()  func mapview(mapview: gmsmapview!, didchangecameraposition position: gmscameraposition!) {     // find visible avatars til limit     let bottomleft = self.mapview.projection.visibleregion().nearleft     let topright = self.mapview.projection.visibleregion().farright     var visiblemarkerset:set<mymarker> = set()     (key, marker) in self.usericons {         if (marker.position.latitude > bottomleft.latitude && marker.position.latitude < topright.latitude && marker.position.longitude > bottomleft.longitude && marker.position.longitude < topright.longitude) {             visiblemarkerset.insert(marker)         }          // not showing if > 50         if (visiblemarkerset.count > 50) {             visiblemarkerset = set()             break         }     }      // remove names     markerwithname in self.iconwithnames {         if (visiblemarkerset.contains(markerwithname) == false) {             markerwithname.removename()         }     }     // add names     visiblemarker in visiblemarkerset {         visiblemarker.addname()     }     self.iconwithnames = visiblemarkerset } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -