I am trying to make a small application using the Google Maps API.
It will display every fastfood location in an area. I know there are already some applications that do the same thing, but I would like to learn and do my own stuff :).
E.g. I have a list of 1000 address, and I would like for every of them to be displayed on the map. S
Should my application send requests 1000 times to Google the longitude and latitude of the location for each time a user would want to use my application?
Or should I store the longitude and the latitude on my database? If so, is there a way to obtain them through a request? I know there is a way to obtain it one by one, not to have all of them.
The Geocoder API has a request limit per API key (you have to obtain one of those): 2500 calls or so per day. I would suggest you use the Geocoder to obtain the Lat and Lon of all your adresses and save them to SQLite, so you can reuse the locations all the time.
Just write a loop that goes through all your adresses, makes the request to google and stores the lat/lon information. If you hit their limit, you can continue the next day.
Related
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
I'm building an app that uses Google places API to get current place if the internet is on. If the internet is off, I use the GPS to fetch and store the coordinates; when, later, the internet is available, I want to translate these coordinates to a place (pass to places API).
Can anybody, please, help?
I couldn't find any method in places API that takes coordinates. I tried to convert coordinates to place id and later use it in places API, but couldn't do it.
The request you do in Places API takes coordinates in the location field.
For instance:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&type=restaurant&keyword=cruise&key=YOUR_API_KEY
So if you already have the coordinates you should just make a request to the API, here you have all the info you need:
https://developers.google.com/places/web-service/search#PlaceSearchRequests
I have created simple android application which take current Latitude and Longitude from google api. then it will store that data to server.
My problem is that every time when i am try to get the Location it show me different value. same place and same phone then also it fetches different data.
this problem is very critical because i am doing some functionality based on the difference of the Latitude and Longitude.
can you tell me how can i get the same lat and long in each devices ?
Thanks in advance
Does it display huge differences or just ~50-100m differences? Because GPS isn't exact (plus it depends on connections, ...).
I am developing a POI locator app. I am parsing a JSON file with over 1600 locations. How would effiecntly compare this list to the current users location and get the closest 10?
EDIT
The app is using no server, as I want to use local JSON files.
I fixed it by using a for loop and measuring the distance between the location and the users location.
distance = locationA.distanceTo(locationB);
if (distance <= 1000 * 10) //finding all within 10km Radius.{
ADD GEOPOINT HERE
}
It's better if you can store the 1600 locations in a database(like mongodb) which supports geo spatial queries. you can directly query over the database to determine the closest N no.of locations to the given latitude and longitude of the user.
If you are going to find distance by a birds-view approach you can just query your locations and check distance with formula located here. But if you are going to take roads (graphs) into accounts, I'm afraid you'll need to use some kind of pathfinding service like google maps or roll your own. (As far as I know there is no built-in mechanism in Android.)
We were writing this kind of app as well, and performed some performance tests on MySQL and MongoDB. Because MongoDB is document based and stores its data in json format, location based queries(like closest restaurants to the user) completes and returns incredibly fast. As far as I can remember, it was approximately 10 times faster than MySQL. So, even if your application doesn' t currently use a no-sql database, I strongly suggest you to use MongoDB even just for location calculating part of your project.
I want to add markers on map for my android app. I do know how to do it (overlay items). My question is: Since I am manually putting markers on points(on the map) whose lat/long's I already know, I want to know if there is any way to get the exact latitude and longitude of a place on google map? Right now I am asking my people to go to the particular places and use this ( http://bit.ly/K4fOcy ) app to determine the lat/long of that place and send it to me via e-mail. I use these lat/long values to put markers on my map in the app. But the latitudes and longitudes i get are not accurate. they have around 300-2500m error (on real scale).
Or shall I use the Google Places API? How does it work? What about the places which are not in the Google Places database? How do I exactly mark them on the map? I would be very grateful if someone points me in the right direction.
Thanks
If you are working with establishments that aren't represented in the Google Places API and want to be able to pull coordinates directly from http://maps.google.com/, you simply:
Find the location of interest on the map, using an address or just knowledge of the area
Right-click on the map and select What's here? from the context pop-up menu
The Lat-Lng coordinates will be automatically populated in the search input box and usually, the address will also be displayed in the dynamic side-panel (and very often a Street-View photo).
If you are looking for a way to query for the coordinates, you can use the Geocoderdev-guide service to turn addresses into coordinates.
Have you looked at the geocoding API for google maps? It allows you to pass in an address, and returns a Latitude/Longitude pair in response, there is an accuracy value returned with each response to let you know how close the geocoder was able to resolve the location. https://developers.google.com/maps/documentation/geocoding/