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.
Related
I have a common use case that I haven't found documentation or examples on. I've added data to my iOS Mapbox app via TileSets in MapBox Studio. I'd like to simply implement a UISearch function on the data in that Tileset using some attribute. For example, I've added a TileSet with 100 different roads in some county in Alaska, and I'd like the user to be able to search for a specific road in the search bar. This seems like it should be easier than I am making it, but I've been working on it for weeks. The original data is geoJSON but I'd like it to be hosted in MapBox Studio so I can update the data without needing to update the app once its released.
Note that this is different than the visibleFeatures function which returns MGLFeatures by location or Rect. I really just need to get all features list from a layer so I can populate it in the UISearch functionality.
Any suggestions? Much appreciated.
Update after talking with Mapbox customer support and folks familiar with how to do this.
Two ways to query features in map:
(1) use the MapBox visibleFeaturesAt() function for features within the rendered map: lots of documentation on this. But this is limited in that it only returns features nearby to your mapview camera. If you want to do a big global search, can't rely on this. So second option is
(2) for global searches, transition to using an external database outside of mapbox. Mapbox isn't designed to be searched up globally for features like this question. If you want to search an attribute that is unrelated map-wise to current view, start using a back-end database like FireBase.
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.
Good day,
I was wondering, is it possible to create "indoor" maps with Mapbox for iOS (or does anyone have another suggestion)? I have a PDF of an indoor floor plan. I think I need to convert that to the MBTiles ( http://mapbox.com/developers/mbtiles/ ) format. How could I acchieve this?
Allso, when drawning the "walking route" for the person to certain facilities in the building. "it" should know where the person could walk.
Currently I am trying to create something with CATiledLayers (but I am kinda stuck (I can display the map, using "a tile" format.) and was looking and MapBox might be usefull since it has things like 'drawning' vectors on the map, or icons with information and such. For the walking directions I was thinkin about 'dotting' the walking routes so "Dijkstra's" algorithm" could determine the path. How could I go about this in Mabbox, even if possible?
Any help in the right directions would be greatly appreciated.
Kind regards,
Matthijn Dijkstra
You can likely do this with MapBox. In order to get an image or PDF into MBTiles format, you will want to use TileMill. You basically need to get your imagery into a geographic format. The easiest way would be to export the PDF as a TIFF, then make it a GeoTIFF and follow these instructions. That will let you geo-enable the imagery, get it into TileMill, then export it as MBTiles. Then, you could use the MapBox iOS SDK to bring it to iOS.
You could use a service such as indoor.io to generate the maps. There are a bunch of indoor services out there and more coming on the market.
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.
I'm working with a project its related to Offline map application.Because of that I searched for offline map which shows the defined area. I used MapBox for offline mapping. I can add annotation on this map and draw lines.
But my requirement is offline map with routing. I was fed up to find a offline routing library or offline routing engine to embedded to Xcode.
Appreciate if any of you have any clue or sample project/code to implement this
Note : This question is related to my one. No one replied to this as well
Thanks.
Offline implies no internet, the iPhone is still able in most cases to get the users current location from the GPS. That means that you can be quite confidant that you can find out the current location of the user whilst offline.
The problem with offline routing is that the Phone is dumb, it only remembers the x amount of MB of data in terms of tiles to display.
Routing is something completely different, it takes a point A and B and works out the shortest, fastest, cheapest or all of those between A and B.
This takes a lot more then tiles to accomplish, after all if you think in terms of MVC, tiles are just the dump views, they don't know much about what's around them except what's inside of them. It would be the "controller" who would calculate routes, and for that you would need to be in possession of all the data spanning the desired area for routing.
For each mapping service you will find a different route, maybe not in terms of actual path, but in estimated time, effort etc, what this means is that if you have your own maps (offline in a database), it's up to you to use that data, so you should make your own routing algorithm which I'm sure isn't what you want to do.
So what are your options? At the moment this just isn't possible in the scope you want. Even if you had an offline maps database, you still need a routing algorithm.
In offline case also you can get the current location by using only GPS and you can draw overlay lines from current location to the interesting point for that you have to do some calculations
You can make offline routing by using graphhopper library by making graph data which contains (Street names, routes,edges) . Graph data is taken by .pbf file which can be taken by (Use this:http://download.geofabrik.de) and use commands(in Terminal) that was given by (https://github.com/graphhopper/graphhopper-ios/tree/master/graphhopper-ios-sample) to convert .pbf into graph data. Then we can make offline routing with its instruction (All given in graphhopper iOS sample).please refer that carefully. because i have done and finish my project successfully.