简体   繁体   中英

iPhone Mapkit Blue Dot / User Location Region Zoom Question

Is is possible to set a region based on a current location in a mapview only one time. I want my iphone app to get the current location, zoom into that current location, and then allow the user to scroll around. However, because my setRegion code is in my didUpdateToLocation function, every time the current location is updated, so is the region, and I can't scroll around on the map. I tried putting this setRegion code in the viewDidLoad function, but the user's current location isn't initialized at this point, so it doesn't work right.

Any ideas?

On this website there is an example of what I think you are after...

http://blog.objectgraph.com/index.php/2009/04/08/iphone-sdk-30-playing-with-map-kit-part-3/

Add a BOOL ivar called say regionHasBeenSet to your class and initialize it to NO in viewDidLoad. In didUpdateToLocation, if regionHasBeenSet is NO then call setRegion and set regionHasBeenSet to YES.

如果您最终在任何时候添加注释,我最近在网上找到了这个代码片段,它对放大有很大帮助: http : //codisllc.com/blog/zoom-mkmapview-to-fit-annotations/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM