Outdooractive / route-me

Open source map library for iOS
Other
122 stars 400 forks source link

location services #59

Closed incanus closed 12 years ago

incanus commented 12 years ago

@trasch, is this something you'd be interested in for your repo?

http://mapbox.com/blog/ios-user-location-services/

It's a pretty big change, but brings it more in line with MapKit. The general code diff overview is here:

https://github.com/mapbox/mapbox-ios-sdk/compare/a55a71f37e02e94d465fed3aaf468962bcab4ff6...mapbox:location

Couple new classes, new additions to the map view delegate, graphical assets, a fair amount of management code in RMMapView, and linking of Core Location.

trasch commented 12 years ago

Yes, this looks great! Can you open a pull request?

incanus commented 12 years ago

Will do, as soon as I stabilize this a bit, as well as get my GitHub pull request issue fixed. Thus far GitHub hasn't been very helpful. I can't make proper pull requests to alpstein/route-me from mapbox/mapbox-ios-sdk -- they don't diff properly and submitting the pull request form fails with a server error.

Any ideas? This has been going on for a couple months now (as you know from some of my code submittals).

fredleefarr commented 12 years ago

Brilliant - looking forward to trying this out.

incanus commented 12 years ago

Ok, my pull request issue is fixed (as evidenced by #60 and #61). Somehow GitHub let me get in a state where I had both a fork of Route-Me as well as your project, which of course is a fork of Route-Me as well. I've cleared that up now with GitHub's support help.

I'll try to get this submitted next week after a bit more work. In the meantime it's in location on mapbox/mapbox-ios-sdk.

jan-christiansen commented 12 years ago

I have implemented a very basic location tracking in my application that does not rotate the map but only moves it if the user location changes. If the user is tracking its location, pinch and double tap zooms are performed next to the point of the user location. In contrast, if the user performs a pan on the map, tracking is turned off. I am curious how you handle zooms while tracking the user location in your implementation.

incanus commented 12 years ago

In mine, I turn off tracking when zooms are performed. However, I've noticed that MapKit doesn't do this, so I may change this behavior to match. The way I do it is through a number of added gesture recognizers that fire simultaneous to the built-in UIScrollView ones that cancel the tracking mode.

https://github.com/mapbox/mapbox-ios-sdk/blob/location/MapView/Map/RMMapView.m#L2022-2041 https://github.com/mapbox/mapbox-ios-sdk/blob/location/MapView/Map/RMMapView.m#L2219-2222

incanus commented 12 years ago

@plancalculus, I've amended my implementation to not disable tracking when zooming the map, either by pinch or two-finger tap. My fix to #63 helped here, too, since it keeps the map centered on the user when zooming in this way. I removed extra gesture recognizers for this and instead respond just to scroll view zooms. I also added a toggle from heading mode to regular tracking mode if the user zooms < z3, much like MapKit, since going out that far runs the risk of seeing areas off the map when rotated.

incanus commented 12 years ago

@trasch, in a discussion on improving the location services, we realized that making the three user location-related items annotations (user dot, accuracy circle, and pulsing halo), some unintended consequences arise when the dev is working with annotations (mostly with clustering and removing dev-added annotations). I've made some fixes to handle most of these, but the ones that remain are that these annotations come back in mapView.annotations, mapView.quadTree.unclusteredAnnotations, etc.

Do you have any thoughts on using the annotations this way? Or do you think it would make more sense to add custom objects for these things that behave just like annotations, but that stay out of the dev's way and are just enabled/disabled with mapView.showsUserLocation?

Relevant annotation-creating code is right about here: https://github.com/mapbox/mapbox-ios-sdk/blob/location/MapView/Map/RMMapView.m#L2059-2150

trasch commented 12 years ago

If you are sure that these will be the only "special" annotations in the map view, I'd say you should make custom annotations for the location marker and handle them separately from the other annotations. If you think that there might be more annotations which are a direct feature of the map (whatever that might be), then we would need a more generic solution to this, but generally im fine with your proposal.

incanus commented 12 years ago

Hmm, ok. I can't think of any other uses like this, at least in line with MapKit behavior. I'll see how difficult it might be to treat them as special cases outside of annotations, but not worry too much about it. Thanks for your thoughts.

jan-christiansen commented 12 years ago

In my application you can also track trains on the map very much like you can track the user location. It might be useful to others as well if it is possible to reuse some parts of the user location tracking in cases like this. For example, I could throw away some of my custom code if it is possible to turn on zooming around the map center even the user location is not tracked.

incanus commented 12 years ago

There's not a lot going on once you've got a given location around which to center the map. From this snippet, it just updates userLocation (optional in this case) and then zooms the map according to the horizontalAccuracy. If you had an exact train point location, you could just center on that and zoom down to [mapView maxZoom] to show the best detail.

trasch commented 12 years ago

BTW, I just found a nice feature in MKMapView (or the Maps app, which is I think pretty much the same). If you zoom in by double tapping the map during activated user tracking and the tap location is somewhere near the center, it will zoom in at the center and not stop the user tracking...

incanus commented 12 years ago

Good catch, @trasch. I'll add that behavior. BTW, this is getting close. Hoping to merge into my own develop this week and probably get a pull request to you as well.

trasch commented 12 years ago

@incanus Great, I'm really looking forward to it!

trasch commented 12 years ago

@incanus Can I help here somewhere? I'm currently between two projects, so I have some time to spare.

incanus commented 12 years ago

Eh, this is pretty much ready to go. Just need to get the pull over to you. Will try to do this week.

incanus commented 12 years ago

I've been polishing the functionality of it and it's been pretty stable for us. Check this out (ignore the marker clipping): https://dl.dropbox.com/u/575564/rotatepins.mov

incanus commented 12 years ago

Ok, this is set in a pull request over in #84. Closing here.