snap to road for apple maps - ios

I have a project which is constrained to working with apple maps, corelocation and apple's mapkit -- 3rd party interfaces aren't allowed.
I need to display a map view showing the user's current location (standard blue dot) and simultaneously place a pin on the road nearest the user's current location -- a 'snap to road' which is a best estimate of the user's nearest location.
I know how to retrieve the user's current address and use the returned street name and address, but i don't know how to add the pin to the resulting street in mkmapview. I've looked at the mkdirectionsrequest but am unsure how to adapt the returned data to solve this problem.
thanks in advance for your help!

I think you can get the road-snapping done by Location Services, by adjusting the location service mode.
Apple's Developer docs on CLLocationManager offer four 'Activity' modes:
Other ~ unspecified
Automotive ~ in a car, truck, road vehicle
Fitness ~ pedestrian related activity
OtherNavigation ~ trains, planes, boats
(no comment about the ambiguity between the first and fourth... there's a bit more detail in the developer docs too than my few-word summaries above)
Basically you set CLActivityType to CLActivityTypeAutomotiveNavigation, and it will do sensible things on the assumption you're in a road vehicle. From what I've seen, this more aggressively snaps to vehicular roads, though you're still limited by the fidelity of Apple's maps.

For a snap to road feature you need the sequence of latitude and longitude coordinates of that street. You usually never get that vector info, because the owner of that vector data (TomTom and Nokia) do not allow that.
Only OpenStreetMap based data is free, and vector data is available.
ios uses TomTom data, and as expecdted you will not get the coordinates of the polyline of a street.

Related

Detecting Which Floor the User is on in a Building in Swift

I am developing the application where the application has to detect which floor the user is on in a building.
I have tried using CLLocation (location.floor?.level) but this value always returns nil.
Please suggest me if there is any other way to get floor level.
TL, DR: unless your location is on the indoor mapping list, floor will be nil.
While it's true that GPS doesn't work indoor, iOS has other tricks to determine users' location when they are inside buildings. You can still get the latitude, longitude and altitude of the user.
The real reason is your location doesn't support indoor mapping. The altitude is measured in meters above / below sea level. Not all cities, or even neighborhoods in the same city, are at the same sea level. Some buildings have taller floors than others. It requires extra work to get that information and Apple has not done that for your location.

IOS Core Location framework accuracy

I am writing an app in Swift to capture and save the location of the phone.
I am planning to use Core Location framework. This framework provides several services that you can use to get and monitor the device’s current location.
Here are a few questions I have:
1. Does Core Location framework uses the phone GPS to get the longitude and latitude or the cell data?
2. What if the phone is in your car, pocket, bag or purse. Can it still get a correct location (longitude and latitude)?
3. If the answer to #2 is false, then what other alternative I have?
Does Core Location framework uses the phone GPS to get the longitude and latitude or the cell data?
It does if it needs GPS for the specified accuracy. When you use Core Location, you tell it how accurate you need to be, and Core Location will turn on GPS if a) GPS is available on the device, and b) it needs GPS to get the accuracy you requested.
What if the phone is in your car, pocket, bag or purse. Can it still get a correct location (longitude and latitude)?
It can, unless it can't. GPS works reasonably well in a car. Pockets, bags, etc. aren't a problem. But GPS receivers do need to be able to receive radio signals from satellites, so if your car is parked on the bottom floor of an underground parking garage, or even if you're just inside a building, it may not work. Core Location will then use whatever other means are available for determining location, such as WiFi and cell tower triangulation.
If the answer to #2 is false, then what other alternative I have?
You really don't have any alternatives to Core Location, but Core Location has a number of ways to determine location. So use it as necessary (and avoid using it when you don't need it, since it does use power) and trust it to do the right thing.

Swift: Maps: How to tell next intersecting street on my route

I am writing an iOS app in swift. I need to be able to tell at any given point in time what street will be intersecting next on my user's route who is driving/walking.
I am able to find the street name user is currently on, the direction user is moving in and also the current coordinates but the last step stumps me: which street will intersect next?
I am open to using Apple Maps, Google Maps, OSM etc as long as it if free.
Your best bet is to use https://developers.google.com/maps/documentation/directions/
The idea is to get the legs of the directions and then determine in which leg you are currently in which you can do since you know the current street name you are in and then find the info about the next leg. It may not always be accurate but its the easiest way that you can find which street will intersect.
You can either use the Driving or Waypoints api.
Hope this helps.

Indoor positioning on iOS with Core Location - not accurate?

Using the sample code provided from WWDC, I've been trying to write a simple proof-of-concept app that performs indoor positioning in my office building. I have a floor plan image and replaced the standard image in the demo code. I've also done the requisite mapping of GPS coordinates to pixels for the two anchor points.
When I run the app in the simulator and specify static GPS coordinates, I see the position updated as expected in the simulator. When I run it on my phone, however, the experience isn't nearly as seamless as Apple advertised in the video. On my iPhone 5s, the positioning is all over the place, and rarely anywhere close to accurate. Even sitting next to a window with a clear line-of-sight to the sky I still get very inaccurate results.
I would assume that this might have something to do with our physical layout, WiFi topology, or other such parameters. However, I also noticed that Apple has a portal where you can register your facility for use with indoor positioning. Does this have something to do with the poor results in my app? I can't imagine how Apple would be able to help with such a scenario, but thought it might have something to do with it.
Are there other steps I should take to increase the accuracy of my app? Is there a way to leverage iBeacons for improved positioning indoors? I haven't found any documentation indicating so, but thought maybe someone here would know.
You're right, Apple has the portal available at https://mapsconnect.apple.com
At this portal you can add your venue and Apple will guide you on setting it up. However, your venue must have all of the following attributes:
Accessible to the general public
Annual visitors in excess of 1 million per year
Availability of complete, accurate, and scaled reference maps
Wi-Fi throughout the area
Associated app that's authorized by venue owner
If your venue has all the required attributes, then you also will need to answer these questions about your usage:
How are you planning to use indoor positioning? (Ads, Navigation, Delivering content)
How many venues would you like to enable with indoor positioning?
What type of venue do you have? (Airport, Hospital, Museum, Mall, Office)
What type of floor plans do you have? (CAD, BIM, GeoJSON, AI, PDF, PNG, etc)
Are the venues equipped with Wi-Fi and/or iBeacon?
Name of the largest venue
Address of the largest venue
Once you have completed the entire form and jumped through the last hoop, you will be brought to a page that confirms the details. Once done, it's all in their hands and they will contact you.
Indoor Positioning does not work well without addional devices like iBeacons.
There is no useable GPS receivement in buildings, the reflected signal is often far worse than 50m .
GPS might work indoors if it is a single floor building with a thin roof, but this is usually not the case in indoor buildings.
The only thing that works well, is to buy some iBeacons and mount them at various locations in the office.
You have to manage the location of that beacons: they only send you an id, and (maybe?) the distance to that iBeacon. (Please check wheter you get distance to beacon)
But ios LocationService will not use that iBeacons.
So either use iBeacons or forget your project. There is no well working solution for indoor positioning. Some use magnetic fields, there is even an App for that, but this needs measuring your whole office in detail.
Why don't you try with the indoor SDK which can be integrated in iOS applications. Also try to give the accuracy level appropriately when you use location framework API.

Adding topography to an Open Street Map based application

I have an application that successfully uses a pre loaded tile cache of Open Street Map .png files for a small city area about 20km x20km to support the presentation of tourist information on the web, iPad and iPhone. It is written in HTML5 and uses MoSync to create the wrapper to deliver it on the mobile devices.
This approach works well for cities but I would like to extend the app to work in countryside areas (in the UK initially) where if I could access it, Ordnance Survey mapping 25000,50000 and 250000 would deliver a much better user experience.
My specific questions are:
How do I get hold of topographic tiles?
Can I get tiles that have the same slippy map structure as OSM.
Can I use Ordnance Survey as a source for the UK and if so is it a one off license fee?
What zoom levels are available? I expect 25000, 50000 and 250000. Is 100000 available?
What formula do I use to identify the specific tile from a lat and long pair?
Will all the tiles at a specified zoom level be the same delta lat and delta long? If not how do I tile them?
Answering a few of your questions:
There are several OSM based maps with topographic elements. Take a look at the list of tile servers and the list of OSM based services. Remember to check each usage policy first before using them in your application.
For determining the filenames of the slippy map for a given latitude, longitude and zoom level, read the slippy map tilenames page in the OSM wiki.

Resources