I need to find a way to get an list of shops/bars etc. around the actual position of the device.
I know how to get the position. I also know about the Google API Places. But is there an way to solve this without using third party libraries?
You can use the MKLocalSearch API's in MapKit, but you can only do a search for one type of building at a time.
More details can be found in the MapKit Programming Guide - Enabling Search
Otherwise you would have to gather and store the data yourself and query your own system.
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 using Google places autocomplete iOS API (as instructed here)
I need to sort the results to show the nearest places first.
Can I do this using the iOS API? if yes, please point me to a reference or something.
Thanks
I think the easiest is to get the user's location, then calculate the distance between each point and the user like this
Calculate distance between two place using latitude-longitude in gmap for iPhone
then order it by the distance.
I am implementing Mapkit in iOS application to make an application which shows posts to users based on his/her location like tinder do. I have tried an algorithm which calculates distance based on coordinates between user and posts. But it seems to be a very costly solution in terms of time, it has a very high complexity, i just wanted to ask is it the right way am doing or should i change my approach. Thank You.
You can you Google API to find the distance between a origin & destination and update the posts aysnc. Hope it helps
Note: You can also pass multiple origins in a single request.
I want to make a nearby stores app kind of like Yelp but with a unique twist. Since I'm starting on iOS an API like MapKit seems like it would be a good way to get location and other data about nearby businesses. However, I don't want to display a map, I just need precise location data and information about the business. Is there a way to do this with MapKit or should I seek another API?
Yes, you can use MKLocalSearch
but I didn't use it as Apple Maps not that powerful in places that my app will be promoted.
also you can use Foursquare API, pretty much sweet API I used it for my tutorials.
Good luck, if you have any further question just ping me.
Is there a Bing API for finding nearby cities given a city name or lat/long combination?
I don't know if Bing provides this, but you build your own from the data available from geonames.org
They provide an API to get places near a given lat/lng: http://api.geonames.org/findNearby?lat=47.3&lng=9&username=demo
Or you can also go all out and implement a solution for your own needs using their data, as per this answer: Given the lat/long coordinates, how can we find out the city/country?
I think this is what you're looking for: Bing Maps API Sample
The short answer is no, there is no Bing API for finding nearby cities.
That said, it would be possible to 'cook your own' using the existing APIs. However, one thing that would need clarification is what 'nearby' means. I presume you mean within a specific radius of a given point (determined by a city name or lat/long combination).
Using the Bing Api it would be fairly trivial to implement an algorithm to reverse geocode a location and then test for places within x distance.
Failing that, you could use something like geoPlugin, it is free and you can put it on your sever - thus avoiding 3rd party up-time issues.
http://www.geoplugin.com/webservices/php#php_class
Take a look at the nearby places features, this does exactly what you want.
http://www.geoplugin.com/webservices/extras
No, there isn't. However, it's relatively simple to get the bounding box for a given coordinate and then use the Bing Maps API with that. I'm doing this and used this solution to get what I needed...
https://stackoverflow.com/a/14314146/73680