Getting surrounding zip codes from a location using Apple Map Kit - ios

I'm getting started on Map Kit for my job and I have a IOS project I am working on where it involves Map Kit, I know how to search for a location and pin point it but my issues is that part of my project involves getting the next 10-15 zip codes of the surrounding areas of my central location and receive the cities that are in each zip code, i really don't know how to implement it and I need help. an explanation or a snippet of code would be much appreciated.

Zip codes like this aren't available in MapKit. You need to find a third-party source of zip code data (e.g. codes + bounding geometries), figure out a way to index them (perhaps be using or precalculating the centroid of each), and then figure out what's close to the selected point.

Use Google Places API for this.
You can go for a Radar or NearbyPlaces search and get zip codes of the returned places (you can use a custom location and set the radius for your search as you are wishing to do).
There is a really good iOS library for querying Google Places API which is FTGooglePlacesAPI
Eventually you can also do everything manually using
NSData* data = [NSData dataWithContentsOfURL:YOUR-googleRequestURL];
and handling the fetched data.

Related

Latitude and Latitude (location name) Upload a file or image from ionic 4 whit angular 7?

How to get file properties should be GPS(latitude and longitude or location name) and upload a file or image from ionic 4?
This is not really the point of StackOverflow, you are supposed to post when you got stuck, not just request tutorials to be custom written for you.
You have also requested two separate tutorials, and the second one is not clearly defined.
I'll try to help though.
To get latitude and longitude you need to read the EXIF data of an image. There are libraries out there and there are guides that show how to use them to calculate the lat/lon info:
https://awik.io/extract-gps-location-exif-data-photos-using-javascript/
For the uploading a file or image then you might find this tutorial helpful to learn the basics:
https://devdactic.com/ionic-4-image-upload-storage/
But that is just a simple example and you will quickly realise you need more complicated code to secure it and multiple servers to deploy it to, and then there are scaling issues and cdn's and more to think about. This is when people generally turn to something like Firebase Storage which will let you push files into the cloud and gives you all the structure without having to write it. Start here for a tutorial that explains these concepts:
https://blog.smartcodehub.com/how-to-upload-an-image-to-firebase-from-an-ionic-4-app/

How to draw a route between two points(annotations) in Swift?

I would like to ask if somebody can help me with a bit of code...I don't know how to create a route in my map in Swift.I just can draw a polyline between two annotations but it goes out of the roads.How can I connect two annotations on map?but connect them on road...all these is for a bus tour.can somebody help me showing me the code for this in Swift?
In order to trace a road like this, you will need data for the road geometry, but none of Apple's APIs provide this info. You will need to find your own source of geo data that both 1) provides point-by-point info for these routes as well as 2) matches the paths drawn in Apple Maps so that you trace lines up properly.
This is not a trivial problem. It's not likely to be done well using just Apple technology.
One way you could accomplish this is:
Use an alternate, open source of data such as OpenStreetMap.
Use a rendering library that draws such data for its basemap, such as Mapbox.
Combine the OSM data-based base map with individual route OSM-based data such as from the Mapbox Directions API.
The bottom line is that since Apple's maps data is closed, you can't guarantee that anything you draw on top of it is an exact matchup. You need rendering and routing data to be from the same source.

How to store openstreetmap data locally on an iphone

I'm working on a project for college and I'm having great difficulty with part of it.
Simply put, I am looking to do the following 5 things:
download the open street map data for my city
store that data locally on the phone's harddrive.
view that data in my iOS application as a map
place markers on the map.
draw paths along roads between those paths.
I have been working on this particular part of the project for a number of weeks and I'm getting nowhere with it. I haven't even been able to figure out how to store the map on the phone let alone view the map data. I've tried using the "Route-Me" library but cannot get it working (although it seems to be one of the best libraries for using openstreetmap data so I am looking to learn how to use it). I feel pretty goddamned defeated.
If anyone has accomplished any of the tasks I am trying to do could you please link me to tutorials/guides/videos that you have used.
I'm not looking for people to give me code or do the work for me, I want to learn how to do this, but if anyone can point me in the right direction of sites that I could learn off I would be very grateful.
Any advice or feedback would be much appreciated
Here's how I ended up solving the problem.
Since Tilemill doesn't natively read .osm/.o5m/.pbf files I used Osmosis to convert a .osm file into .shp files.
I then created a new project in Tilemill and added the particular .shp files I wanted as layers to the new project. It takes a little bit of tinkering to get the map to look like you want it to but it's very similar to css and pretty easy to pick up as you go.
Once I had the map looking the way I wanted it I exported it as a .mbtiles file. This takes a long time to make and the files can be very large depending on how detailed the tiles are. I did one map of Ireland with zoom levels between 7-14 inclusive and I did one map of just Dublin city with zoom levels of 11-17 inclusive. Even though the map of just the city of Dublin had much less tiles, they were both ~200MB in size.
I then found this tutorial online which explains how to store the .mbtiles file in you application and how to read it: http://martinsikora.com/creating-mbtiles-db-for-ios-mapbox-from-hi-res-map-image
Here are a few other links that I found useful:
http://www.kindle-maps.com/blog/using-tilemill-with-openstreetmap-data.html
http://mapbox.com/developers/mbtiles/
http://mapbox.com/mapbox-ios-sdk/api/
http://mapbox.com/developers/api/#static_api
http://support.mapbox.com/discussions
I hope this is useful to someone
I would suggest trying the MapBox iOS SDK. It is actually forked from the Route-Me library and will allow you to accomplish everything on your list.
A key point to remember is that you have another step in between downloading the OSM data and storing it locally on the iOS device, that is, generating the map tiles and storing them in some sort of database.
Here is an example iOS app using the MapBox SDK that has both online and offline map sources and is a good place to start.

Offline reverse geocoding on iOS

There are lots of existing questions relating to this issue, but I have looked at as many of them as I could find and did not get an answer.
I'm trying to perform an offline reverse geocoding lookup on iOS based on a latitude and longitude. I'd like to be able to provide a latitude and longitude, and be provided with the country in which that point lies. I can do this with Geonames (such as: http://api.geonames.org/countryCode?lat=45.03&lng=8.2&username=demo), but I need a similar ability offline, without Internet functionality on the device.
CLLocation does not provide offline services that work reliably enough for what I'm doing, it relies on caches made while you were previously online, etc. Messy.
I've tried this: https://github.com/drodriguez/reversegeocoding but haven't had any luck, it requires some slightly complex / confusing Terminal installations using something called Thor which I've never heard of, and was throwing up a variety of errors, so I bailed on it.
I've found a few downloadable maps, but these seem to be even more complicated, and worryingly, hundreds of megabytes or even gigabytes in size – much beyond the scope of an iOS app. I only need countries, nothing smaller than that (cities, streets, locations, etc.) so I think I should be able to get a much smaller file.
So my key question is: is there some pre-existing database or tool, preferably with iOS support, that I can feed a latitude/longitude, and get a country? And, if not, what steps should I take to get such functionality working on my own?
Thanks in advance.
ReverseGeocodeCountry is a simple lightweight offline country reverse geocoder for iOS, it has a static JSON file with country polygon data that is used to reverse geocode any lat/lng:
https://github.com/krisrak/ios-offline-reverse-geocode-country
The "Countries of the World" is a .csv text file with countries, coordinates, localised country names, capitals and other information. It seems to be free to use. You just have to import it into an SQLite database.
Edit Just noticed you want reverse geocoding. The database would only be good for forward geocoding.
You can download shapefiles for all countries at http://www.gadm.org/download. If you download a .kmz, you can unpack it to a list of coordinates for the borders. You could probably take every 5th or 10th coordinate to get smaller size (with less accuracy).
Just in case I can suggest another good written offline geocoding library.
https://github.com/Alterplay/APOfflineReverseGeocoding

iOS MapKit Showing Many Places From File

Im relatively new to iOS development and have been asked to make an app whereby I can place a load of pins on a map. I have been given an csv file with the lat, long, an identifier and some info for each of the places I need to plot but I'm not sure as to the best way to go from here. Any help is very appreciated!!
My Advise is to divide your task:
1 - Create a class to hold your coordinates and other useful information (name of the place, phone number, etc)
2- Create a parser, so you can parse your CSV file.
3- Add your data to your map.
Use the following links to help you out:
Import csv data (SDK iphone)
http://blog.objectgraph.com/index.php/2009/04/03/iphone-sdk-30-playing-with-map-kit-part-2/
Since you are new to this, take your time understanding what's going on. There are no shortcuts when learning. If you need more help, use my email so I can assist you.

Resources