Getting events from a location - android

I was wondering if anyone has been working with this facebook-events-by-location library, because I've tried it myself and came across 2 potential problems:
The result list is too short (only about 20 items)
Some of the events are from another country (Germany) and have nothing to do with being nearby the provided location
What would you suggest that I obtain more events, and more importantly, ones that are in the nearby location?
Is there any other library like this one, or maybe there is a simpler way to directly use the Facebook Graph API and obtain more events by location?
Extra: do you need to some sort of premium (paid) account for the Facebook Graph API in order to get more results?

You can only search for Places by location, and then get the Events of those Places. That´s what the package actually does, if you take a look at the source or the Readme. The limit for Places is set to 100, and if there are only 20 Events in those 100 Places, you will not get more.
There is no API to get events by location, that package only a workaround. Also, there is no premium/paid account for the Graph API, it is just not possible (directly).

Related

Is there a way to get a list of places based on a specific location in Android Development?

I've been looking at the Places API from Google for this, but I don't know if this is the right direction to take. The project revolves around finding a list of places based on a specific location, other than the current location (for instance, what kind of restaurants are around your friend's house (based on longitude and latitude)). Most of what I've seen with the Places API involves using the user's current location. Is there a way to pass in a predetermined location? Or can I fool it into thinking that location is my current location?
I think still places is the best option for you, you have to really understand the api to get what you need from it. Look at how could you send a request to the places api with a given location (long, ltd) and it will return nearby places.
https://developers.google.com/maps/documentation/places/web-service/search-find-place#locationbias

Get total "Areas/Zones" in which I am currently in, based on Current Location

Let us suppose we have three hotels:
Hotel A (popular in 1 km radius), Hotel B (popular in 2 km radius) and Hotel C (popular in 4 km radius). A car enters and is at some position. These Hotels (or any other place) is added by us and is custom.
Problem is I want to find the hotels which have popularity/influence at my current location.
And I want it to do totally with the help of Google Maps. Is it feasible ? on Android (optional)? Please ELI5.
Google Maps API has a function called computeDistanceBetween. It "returns the distance, in meters, between two latitude/longitude coordinates". Circle has the Center and Radius properties. So you need to calculate the distance between the center of a circle and you current location. If it's less than the radius of the circle, than it means your current location is within the circle.
Simplifying is key
Although I understand your objective (get a list of all hotels near you) I believe your explanation threw many people off guard. You don't need to triangulate positions and calculate radius of circles - not with Google Maps APIs and Services.
All you need to know is if you want a solution for front-end, back-end, or mobile
Google Maps Places API Web Service (back-end)
The Places API has a very useful feature called "Places Nearby". To quote the documentation of this feature:
A Nearby Search lets you search for places within a specified area.
You can refine your search request by supplying keywords or specifying
the type of place you are searching for.
Which looks exactly like what you need, right ?
To make a request from a server to the Places API Web Service looking for nearby places, you can do the following:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&type=restaurant&name=cruise&key=YOUR_API_KEY
Do remember to change the key=YOUR_API_KEY to a valid key field. The example showed will look for restaurants in a radius of 500 meters around the location of -33.8670522,151.1957362.
There are a lot of parameters to this and you can read more about this in the following documentation
https://developers.google.com/places/web-service/search
Google Maps JavaScript API with Places Library (front-end)
If you however don't have a central server or service to make requests for you, making the clients send the requests directly is also an option.
In this case, there is the JavaScript API. The JavaScript API is a client-side friendly API that re-uses some of the Web Service's features.
In this case, you can use the JavaScript API in conjunction with the Places Library for it. According to the documentation, this API allows you to do "Nearby Search Requests":
A Nearby Search lets you search for places within a specified area by
keyword or type
An example of such a request can be seen in a live example in the following link https://developers.google.com/maps/documentation/javascript/examples/place-search
You can read more about the parameters and usage of this API and this library in the following documentation https://developers.google.com/maps/documentation/javascript/places#place_search_requests
Google Maps Android API (mobile)
From the picture you added, I assume your app will be to "use on the go" (perhaps a mobile app), or something similar.
In this scenario, using a web-server or a website could be cumbersome, as by the time you have a response from it, the car is already in another position !
To aid you in this, there is also the Android API. To use it you need to:
Download and Install Android Studio
Add Google Play Services Package (contains APIs you will use)
You can read more about this process here https://developers.google.com/maps/documentation/android-api/start
As for code and examples, I strongly suggest you check out this GitHub repository of samples
https://github.com/googlemaps/android-samples
Our Hotels may not show up on Google Maps
Unless your DeLorean takes you back to the latter half of the 19th century, or you are stuck in an island with hundreds of Meerkats, poisonous pools and a tiger wondering if he should eat you or not, Google Maps will pretty much always show you some hotels where you can spend the night.
PS: kudos++ if someone gets my references :P
Adding Hotels and Places to Google Maps APIs and Services
If this is still not enough however, there is still a way you can fix it. You can add Hotels addresses and Places to Google Maps by using one for the two following methods:
Send Feedback
Use Maps Maker
Send Feedback
The "Send Feedback" feature allows you to send feedback to Google's data teams for review. Once approved, the data is added to Google's database and will be available to all Google's customers. You can do this by following the steps described here https://support.google.com/maps/answer/3094045?co=GENIE.Platform%3DDesktop&hl=en
Please do note however that the review process for your feedback will take some time, so don't expect anything instantaneous !
Use Maps Maker
Alternatively, you can use Maps Maker. This tool allows you to do edits and add information to our Services in a more streamlined manner.
At first, your edits and suggestions will still be reviewed, and it will usually take less than two weeks to get something approved.
However, with time, as more and more of you suggestiogns are approved, you gain reputation, and when you have a lot of reputation, your suggestions will be pretty much automatically added.
Before using it however, make sure you have a look at the list of supported countries.
Also, if language is important, you may want to consider it as well, by checking the list of supported languages.
I really don't want to add anything to Google Maps
Sometimes the whole business is data itself, so giving it out freely is not an option.
In these cases, you will have you own database, which your services will have to check.
In cases like this a custom solution for your system is needed, but in order to suggest a few more ideas, more information is needed.
Hope it helps !
Your approach should use fast approximate calculations without relying on apis, and then api usage can be used to enhance user experience.
You know the coordinates of the car.
You know the coordinates of each of the hotels.
Assign a popularity weight to each hotel based on your criteria or data you have. e.g a hotel having more user reviews or transactions or bookings will have higher influence, or if you want to personalize, a hotel which suits the loggedin user's budget preferences ( based on past data or settings ) will have higher influence. Lets call this popularity value p1,p2..p3 etc.
Find all hotels that lie within a threshold range, say 5kms within current position of the car. This can be done using a geospatial query in any major storage database ( for example if your hotel points are stored in MySQL, or mongodb ), or if you are using a hotel data api, get the nearby hotels,or all hotels of that city, and prune them based on distance from car's current location.
For linear distance between the car C, and the hotels H1, H2... use Haversine formula , this will give you distance between the Car and any hotel along the Earths curvature. ( Actual road distance might vary, as roads are directions aren't straight and involve turns etc). But this will give you a fast approximation of distances D1 between C & H1, D2 between C & H2 etc...
Now decay the popularity score P1...PN of each hotel based on distance between the Car C and the hotel H. For example if hotel H1 has popularity score P1= 90, and hotel H2 has popularity score P2=90, but C <---> H1 distance is 10kms, and C<--->H2 distance is 2kms,
then H2 will have more influence on the current location compared to H1.
A simple formula can be LocationInfluence = PopularityScore/ log(Distance), you can optimize this based on your use case.
Now for the most influential hotels H1,H2,H3... use DistanceMatrix api to find actual driving distance, you can also use google maps directions api for Android or Javascript to show driving directions to the user, from location till the hotel.

Android: access saved google locations programmatically

Google maps allows the possibility of saving favourite locations for ease of access later... see here.
In Android, where a location is required to be entered, it would be neat if there were an API to enable the user to choose from their already-saved favourite locations, e.g. via a picker dialog or something along those lines.
I can't find such an API... is there? The closest I've found is this and this, but these don't seem to allow picking from your stored locations.
There really isn't a way to do this, but you could create your own method to do it. You could have an ImageButton with a star (or anything that symbolizes 'save'). Use SharedPreferences to save the latitudes and longitudes that the users have entered, and then every time the application is loaded up, you could check to see if there are some values in the SharedPreferences. If there are, you could use a ListView to show all the saved locations, and then when one is clicked, return to the parent activity with the Location. Finally, use the Location to orient the map correctly.
Google/Android doesn't provide any public API to access the starred/frequent locations of a user and that data is only shared amongst the Google apps.
As this answer shows it might be possible to fetch location data via the Google Plus and Google Identity platform APIs
Alternatively (or in addition to), using Google's Plus Platform /
Google Identity Platform, if you have an authenticated user, you can
make an API call as described here (with examples) to get any of the
specified fields for the current user (including currentLocation,
organizations (including work) with addresses, if the user provided
them).
Take a look at this link.

How to fetch city events?

I wanted to venture into making apps. I wanted to make an app that gathers the events around the user location wise. I want the app to show the events close to user using the GPS of the phone. There is a city page where all the events are listed but I don't have any ideas how I will be able to fetch the data. What are the other ways I can go forward with this? It would be encouraging so that I can research further.
try this
http://www.last.fm/api/show/geo.getEvents
login this and get the api calls and use it in your code
i think you can use a combination of api's to give you the data you are looking for, one such provider i found was http://api.eventful.com/, you can probably even try including foursqaure and meetup's api and even facebook opengraph event api can also provide some handy data.

How can I take a text query, and get a location in Android?

I was wondering how I can channel or simulate Google Maps just in the sense of a user types in a location in text, such as a restaurant name and a city name. Then Google suggests 5 or so places they have indexed, and presumably they know the GPS coordinates because Google then puts them on a map. I want to be able to use that feature- not the map, just getting the location.
My goal is for a user to type in a query, 5 options or so to be shown, and if they user chooses one of them, then the GPS coordinates, or a location object, is saved representing that place.
Ideally I could just send the query to Google and steal the results back to my app. Obviously building my own database of locations and an algorithm to suggest them is out of the question.
Thanks for the help and advice in advanced!
Note 1: To clarify, this does NOT involve the current position of the user/device.
Note 2: I looked at the Google Maps add-on API, but it looks like that is for a visual map, not the querying a location part. You are already supposed to know your location, and it will map it.
Use geocoder.getFromLocationName, you get back a list of Address objects, in those objects you will find all the information you need about the location.
To test this on the simulator you need an image with the Google APIs included. In a device should be fine if you have the market installed.

Categories

Resources