Is there a Google Maps equivalent to mkmapsnapshotter?

偶尔善良 提交于 2019-12-06 02:57:23

问题


I have a UITableView which may potentially contain a large number of cells, and in some cells I want a UIImageView showing a map of a location, the coordinates of which are known only at runtime.

I want the table view to scroll smoothly and I want the maps in the cells to not be scrollable at all.

I've been directed to avoid Apple Maps. Besides, MKMapSnapshotter is iOS 7 and up. I have to support iOS 6.

So is Google Maps image API my best option?

I'm already using the Google Maps iOS SDK anyway, so I'd like to use it for this if possible. But does it have this feature? An equivalent to MKMapSnapshotter? I'm surprised I can't find it in the documentation.


回答1:


There used to be a GMSScreenshot class in the SDK, that could be used to take screenshots. However in v1.2 Google removed this, as you could use renderInContext instead. You can see some background info and sample code here:

Google Maps IOS SDK 1.2 need snapshot of map view

Issue taking screen capture of GMSMapView on Google Maps SDK for iOS

https://developers.google.com/maps/documentation/ios/releases#version_12_-_april_2013

I think though that renderInContext (and GMSScreenshot before it) is designed for taking a screenshot of a map view that is already on a view, has been displayed for a while, has downloaded map tiles etc. I'm not sure that it would work well if you created a map view in the background, set the camera position to your desired lat/lon, rendered it to an image, and then repeated for the other locations you want.

So, I suspect that the Google Maps image API would work better for what you are doing.



来源:https://stackoverflow.com/questions/26266947/is-there-a-google-maps-equivalent-to-mkmapsnapshotter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!