How to search using the twitter API by country? - geolocation

Ideally I would like to be able to search tweets by country however search/tweets endpoint only supports geocode in the format of "latitude,longitude,radius" unlike the streaming endpoint which you can set a bounding box.
How do you best search by country?
As a simple solution I have thought about calculating the centre of the bounding box along with the smallest radius to remain in the bounding box.

Related

Compute Heading iOS mapkit

I am working on functionality where I need to animate car driving on the map which is similar to what Uber has for customer application.
Current approach: I receive latest driver's coordinate from the api after particular polling interval, I use latest lat long and last known lat long to calculate directions using MKDirection. Currently I am able to animate car on this polyline received via directions api but I am not sure how to calculate heading to rotate car in a particular directions.
Note: Client's requirement is to use apple's native maps and api available and not to use Google Maps api.
Any insights on computing heading will be helpful.
Have you looked at this answer? https://stackoverflow.com/a/12696424/1364963
This should outline how to calculate a heading from two GPS coordinates.

How can I select nearby search results when using Google Maps SDK for iOS

I am building an iOS map with local search functionality similar to Yelp.
The user will see a local map generated from Google Maps SDK from iOS, and local points of interest returned by the search, will be displayed on the map as custom markers. Simultaneously, the user can also see these same local search results in a list form on another screen.
My issue is as follows: to optimize loading time, I would like the app to load only the search results within the area displayed by the map, given the coordinates of the center of the map, and the zoom level. This would be more efficient than loading, say, all search results within a 30 km radius, most of which may not be visible on the map. Is there a simple way to know exactly what are the coordinates of the area displayed by the map on the user's phone (bottom left corner, top right corner)?
I have seen other posts online, explaining how the coordinates of the area can be calculated using zoom level, latitude, and screen resolution. However I am wondering if there is a simpler way commonly used by other apps that display local points of interest.
Thank you!

MKMapKit and points of interest

In the Maps app for iOS, if you tap on a point of interest it displays relevant information about that POI. For example if you tap on the train station icon, it displays the name of the station.
Is it possible to replicate this behaviour using MKMapKit? The icons for the POIs are there on the map, but of course tapping on them does nothing. I've tried reverse geocoding based on where the user tapped, but this just gives me a street address, no data about the POI.
Another strategy I've tried is to use Google Places API, to load POIs within the visible map region, and then setup annotations for each of those POIs. The problem is that this API has a limit of 20 results, so it doesn't work too well in a dense area.
Anyone have any ideas on how I could achieve this?

Efficent way of determining country polygon touches on a MKMapView?

When a user taps a point on an MKMapView in my application, I want to determine what country they tapped on. Speed is my priority, since a user will definitely notice the lag between a map touch and an annotation callout begin presented with the name of the country.
I have the polygon information for all the countries and I can parse/store them in any kind of data structure necessary. Currently, they are in GeoJSON format and have thousands of verticies. I also have bounding boxes computed and stored for each country.
One suggestion was to store an array of CGRects for each polygon's bounding box and first doing a CGRectContainsPoint search on all the bounding boxes to quickly narrow down the search. If that search returns multiple bounding boxes (common on country borders where the bounding boxes can overlap) then I can check the filtered country's full polygon for the point in question. Even on very congested overlapping areas, this full search would be 5 or less full country polygons to check.
To accomplish this, I'll need to store both a CGRect bounding box and a full, complex CGPath for each country. (and a country can have multiple polygons if it has territories) I don't know if storing these in-memory is a good idea, since there are potentially many thousands of polygons.
Compiling SpatiaLite is not an option because of the licensing requirements for GEOS. Compiling SQLite with the R-Tree extension is a possibility. The polygons do not change, so I'm able to precompute and store them on disk in any way that is suggested.
If I follow this suggestion, what is the best way to store and access all these CGRect and CGPaths for quick searching and access?
I'm open to any other suggestions people have.
I would recommend either using the Mapbox iOS SDK or at least using the RMInteractiveSource and RMMBTilesSource parts of it. You can use TileMill to turn your source data into raster tiles with encoded interactivity info on a per-pixel basis. Here's an example: https://github.com/mapbox/mapbox-ios-example The interactivity data is basically a highly efficient key-value store on a per-pixel basis. You can then convert a CGPoint at a given map zoom level and panning offset into the value.
Technology background: https://www.mapbox.com/developers/utfgrid/

What nice map can allow streets on top of polygons

I would like to use something like google, mapquest, bing, or openlayers to try and get something that looks like
http://screencast.com/t/qZejYb0L3Er
where the major streets are unaffected by the polygon overlay.
Can someone point me in the right direction. From the google api documentation it would appear i cant get under the roads so... looking for some help.
You can do it with Google Maps by changing the order of the layers.
This is an API V2 example, but you can achieve the same result with the current version, which is V3.
We ended up using http://www.mapdotnet.com/ with background from open maps. Custom middle cache tiles from shape files stored in SQL, on top we have open street layer (or can use bing)

Resources