我已在我的应用程序中集成了Google地图,并使用了Google Places API.在我从Google Places API(大约60)获得所有结果后,我将在自定义标记的帮助下显示它们.我制作的自定义标记包含"Place Image"和"Place Name",因为我必须首先在UIView中绘制它,然后借助以下函数将其渲染为UIImage
- (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;
}
Run Code Online (Sandbox Code Playgroud)
首先,所有标记都可以轻松渲染和绘制.
现在我有一个100米到5千米的滑块,它可以作为搜索半径优化器.当滑块移动时(假设值为2km),则移除所有标记,并且仅再次绘制与用户位置的距离小于滑块值的那些标记.当我测试滑块功能时,应用程序崩溃说
((null))为false:达到纹理图集的最大数量,不能分配更多.
我正在上传屏幕截图,以便清楚了解情况.请帮忙.
另外,在屏幕中,您将看到绿色标记以及蓝色标记.蓝色标记是靠近用户位置的标记,而绿色标记远离特定距离.由于用户位置将发生变化,因此有两种情况: