I'm trying to build an application with Java where I need to define some custom areas which are not readily available (e.g. jurisdictions for different police stations or fire stations in a city). My goal is to find out that, given an user's location, which jurisdiction that is a part of. I tried the Google Maps API, but couldn't find a solution.
Can anyone please help me find the solution using Google Maps API or any other API.
You can try using PolyUtil.containsLocation(LatLng point, List polygon, boolean geodesic) from Android-map-utils
That given the list of latitude and longitude that defines your custom areas you can check if current location is inside or not.
Related
As a newbie I'm making a Java desktop application based on OpenStreetmap, jXMapKit library.
What I have actually done is displaying map and possibility to center possition by typing X and Y coordinates.
Moreover I would like to display/load on my map some places like: cinema, theater etc. but I don't have any idea how to do it.
Is there any chance to download some list of places from any website and display it on my app?
Regards
Take a look at Overpass API. For downloading specific POIs you need to know their key-value-pairs. For cinemas this is would be amenity=cinema. Also take a look at overpass-turbo. This is a webfrontend for Overpass API and allows you to play around with your queries and to visualize the results.
How can I implement an interactive map using Google Maps API that prompts a user to select a route? For example, the Place Picker (https://developers.google.com/places/android-api/placepicker) is an interactive map that allows the user to search and select a location and I can get that information using onActivityResult(). I am looking to do something similar, but for a specific route from point A to B.
The easiest way I can think of for getting this information currently is to use the PlacePicker to get the user to choose origin and destination. Then I would use the Directions API to get the available routes. Then plot the available routes on a map and prompt the user to choose one. But this way seems a bit messy and I would like it if the user could just do everything in 1 interactive map that returns a specific route to the app.
Any suggestions on implementing the cleaner solution? What combination of Google Maps APIs could I use to achieve it?
This javascript-related question acheives something similar to what you are asking, but not with the Android API. Two possible ways forward would be:
Use the API in a similar way to them, with waypoints and directional
arrows.
Do what they did in a browser (for example in HTMLView) and put an
invisible View on top to get the clicks and select the route that way
(change the color of the selected route after getting the click).
The key information from the answer linked and others around the web seems to be to use Multiple DirectionsRenderer objects, possibly stacked in an Array.
Me and My group are doing a Map project for my University Campus. we considered using google maps and its directions apit to do building to building and user location to building and eventually room to room. the problem is that because the paths on our campus are not mapped so unless we do manual routes and that would take to long. is there any alternative map/directions Api that we anc use that woudl just as well?
see this top-10-mapping-apis and this Comparison_of_web_map_services
i suggest u to use mapquest.
i want to build a weather app and i have some problems.
my big problems is places names! you know, i want that user find his location with two ways. with GPS and by searching. but my problem is that place names. how can find a database from whole places in the world?!
is it good idea that i store them in a database in my server? or there is some services that provide this functionality? if i have to create my own database how i can create a database like that. is there a database with city names and latitude/ longitude and other information? if a new location created how i can add it to the system? by hand?
the second problem is that after catching the city name how i can find that locations latitude/ longitude? it seems google has a Geocoder service but i don't know how it works. please help me. i just want to select a city name and find related coordinates...
The Google Maps API provides you with Geocoding, which allows you to turn strings like 'Santiago, Chile' or 'New York', into proper latitude/longitude coordinates. So in your code, you should perform an HTTP GET request to a URL like this one:
http://maps.googleapis.com/maps/api/geocode/json?address=Santiago,+Chile&sensor=true
And it returns a JSON object with a properly formatted address along with latitude and longitude information of the place you were looking up.
It's explained very thoroughly in the Google Maps API Geocoder documentation, so you should probably take a look at that. I'm no expert in Android development, but there should be some library that allows you to easily access what the Maps API has to offer in a clean way.
Maps API also provides you with a solution for Place Searching, and even input autocompletion, but all the examples I see are on JavaScript/HTML, so I'm not completely sure if there's an alternative in plain Java/Android to what you're trying to do. Nevertheless, you should take a look at basic place searching and place search autocompletion so you get a general sense of how it works.
There's an entire section in the Google Developers website dedicated to the Maps API on Android, so make sure to take a look at that aswell and you might find more useful information - sadly I have no experience with Android whatsoever so I can't really point you in any direction.
Good luck!
You could use the Google Maps Geocoding API. Querying coordinates returns a JSON response containing the current location in multiple levels of detail that you could parse.
E.g. for the position lat:40.714224 long: -73.961452, the query URL would look like the following:
http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=false
The result now contains the city and country, beside much more.
You can find more information on the API here: https://developers.google.com/maps/documentation/geocoding/
You could also try http://openweathermap.org/
I haven't used this extensively but I tried it enough that I know it works. It lets you query by location name or geographic coordinates, and the city name is included in the responses along with plenty of other data.
http://api.openweathermap.org/data/2.5/weather?lat=xx&lon=xx returns a weather object with city name & related data. API key is even optional so you can try it out very quickly.
For my CS bachelors I am doing a Senior project using android and google maps.
My vision was to do a (relatively) simple Dijkstra shortest path using google maps road data. I was going to add elevation change along with 2D distance. I am doing well playing with maps in android but I am completely stumped trying to access google maps data in any sort of searchable form.
How would I go about accessing the data for say intersections of roads (lat/long) in a particular area?
There has to be a way to pull that data in some sort of tree form. It seems like it may be possible with kml?
Any pointers would be awesome.
I want my paths to follow roads but If i cant this is going to turn into an orienteering application fairly fast.
Jeff
You might want to look into http://www.openstreetmap.org/ instead, they have the lat/long points of streets available for view. Google and others buy theirs, which keeps you from being allowed to access the raw information.
I don't believe you can access raw road data from Google Maps (such information is very valuable - if Google gave it out for free I can see car navigation companies going bust!). The best you can do is get the end result.