Closest of a list of addresses from a location - google-maps

does anyone know how i can return a googlemap with pins for every location within a set radius. Don't necessarily need a specific distance from potential plotted route. I want the user to be able to specify their address (postcode) and a set distance (10,20,50 miles) and then i can show these results on a map. I have the list of postcodes, held in my database, do i need to generate something like a kml?
Cheers
Tim

This sounds like a classic Store Locator application, which is a bit complex to detail in an SE answer.
Google have an example documented, though.

Related

Search for places around current location of the user - PlaceAutocompleteFragment

What I need to do is implementing a PlaceAutocompleteFragment view to look for places around the user's current location.
I was taking a look at the official documentation but couldn't find a proper way to do it.
I've set a Place.TYPE_COUNTRY filter but it shows predictions of places all around the country and most of the results shown when typing are irrelevant for the user.
AutocompleteFilter filter = new AutocompleteFilter.Builder()
.setTypeFilter(Place.TYPE_COUNTRY)
.setCountry(country)
.build();
The PlaceAutocompleteFragment.setBoundsBias(LatLngBounds) method provides a way to restrict results to a specific region.
autocompleteFragment.setBoundsBias(new LatLngBounds(
new LatLng(-33.880490, 151.184363),
new LatLng(-33.858754, 151.229596)));
According to the documentation the code above restricts results to a specific region of Sydney, Australia. I think this is similar to what I want to get.
So the question is, is there a way to get the LatLng values to instantiate the LatLngBounds object programatically?
I mean, I want to get that values dinamically based on the current location of the user.
Do you just need the device's location? If so see Making Your App Location-Aware. You can then expand this into a bounding rect (one way is to use SphericalUtil.computeOffset() from the android-maps-utils library)
Finally, note that the bounds is not a strict restrict on results, it only biases results to the bounds.
Or are you asking how to find out what a good bounds would be to use for an arbitrary city/region in the world where the device is located? If so, then you could do the following
Do a reverse geocode lookup on the device's location using the Google Geocoding API.
Examine the results and pick the result at locality level?
Use the viewport of that result as the bounds.

Set location on google map

I have created one small application, where user can store his/her contacts with full address including map. Therefore I am using the Google Maps API, where user can point out his/her address.
For this I have given address fields with Country, State and City. When user entered this information, I am showing the default address on Google Maps, then the user has to drag the marker/pointer onto his/her exact location.
Now, in this case I want the zoom level of googles map to be set as per location's population.
This means if the user entered city with no mans land (less population or any desert place or any jungle place or very small area on city then zoom level should be more, so user can see proper area on map) otherwise zoom level should be less.
Can some one guide me how to do this?
This won't be possible using the Google API's alone, (I'm unsure if demographics info has been released for the US, I know it was in the works, but it certainly won't work elsewhere). You will have to find an external source to provide your demographics information for you.
The Google API's do not keep a public record of population density.
You could however be a but more tricksy and use an approximation. You could for example do a places search in the area (using an arbitrary radius), count the number of results and use this to set your zoom level (again using an arbitrary value to determine high/medium/low etc). It's a fair assumption (though still an assumption) that any area with a large number of 'places' returned will be densely populated.
You don't need to base this on the population of the location. Please check the follwing link. I think it should give you an idea of the options you have.
Google Maps API v3 - Geocoder results issue with bounds
Check both my question and my answer. You will probably want to use the viewport object.

How to compare Google Maps coordinates on an accurate way?

I have the coordinates(lat, lng) and the information associated to this point in an excel sheet.
I want to compare the coordinates that I have stored on a database(lat, lng) with the excel ones.
My main idea is to show the correct info about the road point on the info window associated to the marker.
My doubt is about how to choose the coordinates on the most accurate way?.
Any suggestion?
So I think I understand what you are doing - capturing the coordinates of a user's location and then you want to find information about what is nearby to that location. If I have that correct, I suggest you take a look at the Places Library.
Google provides a library/service that allows you to send a requestthat includes a location and radius or coordinates that define a rectangular bounds and the service will return information about nearby places of interest. There are many ways to refine the searches to focus on different types of features.
I think this is what you are looking for - if not, provide a little more detail and I will try to help you.

Plot coordinates near a given set of coordinates on Google maps

This is the scenario...
I have a set of lat/long data stored in a db table[id, lat, long, location]. I'm using geo-location to get a user's current physical location(lat and long). When this user accesses the app, allows his location to be shared, I want to get those coordinates that are around his current coordinates, and plot them on a Google Map.
How can this be done?
Example: I have the coordinates for hotels in a city stored in my DB table. When a user visits this city and accesses my app, I want to get from my DB and plot on map only those coordinates that are around him in a certain radius.
Note: I'm using PHP for server side stuff.
Any help is appreciated!
You describe a store locator: finding POIs within a radius around a particular point. A store locator finds POIs within a radius around a location. The details in Google's example are different (you find the centre point via browser geolocation and have a fairly small radius) but the principle is exactly the same.
Google's article: developers.google.com/maps/articles/phpsqlajax_v3

highlight a list of streets on a map

We have a database of addresses that we deliver to. It consists of the following data;
StreetName
NumberFrom
NumberTo
ZipcodeId (points to seperate table with zipcodes, which holds cityName)
StoreId
Would it be possible to highlight all those addrresses on a map like GoogleMaps (preferred), Bing, OpenStreetMap, etc. ?
I know how to add polylines, and have done geocoding in the past for addresses.
A possible issue with the data, is where it covers whole street they practise have been to just set the NumberTo to 9999. If i plot an address into google Earth with 'StreetName 999, City' it will place the point in the middle of the length of the street.
Also tried a random number, and it placed the marker on a building instead of on the street.
I don't know if it's different for GoogleMaps..
Update
I think that the DirectionsService in GoogleMaps API is the way to go, now i only need to figure out if and how i can use it multiple times on a map.
Success!
I was able to iterate over all the addresses, doing a DirectionsService request for each addres, from start of street to end of street. Extract the GeoPoints used by DirectionsDisplay, stored it to the database and is now able to draw Polylines on a map for each road.
I could iterate over the addresseseach time the map is shown (in-house use only). But still this would be a performance issue, and also unsure if how many request Google will handle per day. By storing it in DB i only need Google to calculate it once.
It can, but only in certain areas of the world - e.g. US
But you need to prepare your adresses - lets say in div/spans - then on onload document, you calll the API
I did this using Lat/Lng from a Garmin Edge - the difference is that you need to translate your addresses into lat/lng, before you can position these on the map canvas.
Mike
Yes you can convert the Address to a GeoPoint and then plot the GeoPoints on the Map. Start by looking here