How to show multiple location markers using Google Map API? - java

Problem description:
I have to develop an application using Dynamic Google Map in Spring MVC to show multiple 'Bubble Markers' using address/postal code
and I have to show zooming facility for this map, when I click on that Bubble it have to show the corresponding address or postal code.
What I did yet :
I have implemented static Google map to show multiple 'Bubble markers' using postal code.
As following code
http://maps.google.com/maps/api/staticmap?center=099419&size=512x512&maptype=roadmap&sensor=false&markers=color:blue|label:S|416416|238843
One more problem with this static way, I can not put many postal code because of fixed length of URL.
so how can I implement this ?

follow this sample of goolge maps and make an array of marker.
Link
Or this:
Link2

Related

Limit Android Google Places API to search only given area

I`m using Android Google Places API to autocomplete streets and addresses. The problem is that it gives all streets from a whole country. Of course I added bounds to limit place for search, but it doesnt work correctly - it gives only priority, so in other words best results will be higher in list, nothing more
So code:
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
.setCountry("RU")
.build();
Intent intent =
new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
.zzih(searchString) //that is for passing search string from toolbar
.setFilter(typeFilter)
.setBoundsBias(city.getBounds())
.build(this);
In short the problem is:
When I type in search something like "Lenina Street" I see a lot of useless results out of bounds set in .setBoundsBias(city.getBounds()). Just imagine that something like "Lenina Street" exists in almost every locality!
How can I fix the problem and limit search results?
P.S.
I know I can use Google Places Web API or by GeoDataApi.getAutocompletePredictions() and filter results manually,
but that means I have to write UI manually too, what I dont want to
do.
Thats even worse than I thought. Even if I get results from Web API or through GeoDataApi I have only predictions which doesnt contain coordinates, only placeId. So if I want to filter predictions by coordinates I have to do request for each placeId. In other words if I got 20 places I will have to do 20 more requests to find out coordinates.
Also I can add city name in searchString, that makes results better (but not at all) but it makes writing of address unclear and city name takes place, so its not good solution too.
I'm afraid Places API for Android doesn't support strict bounds yet. There is a feature request in Google Issue tracker to implement this:
https://issuetracker.google.com/issues/38188994
Feel free to star this feature request to add your vote and subscribe to notifications from Google.
In the meantime the workaround might be using Places API web service that supports strict bounds and implement the UI manually.
UPDATE
The feature request was marked as Fixed by Google. Have a look at https://stackoverflow.com/a/50134855/5140781 that shows how to apply strict bounds in Places API for Android.

How do I pass and extract data in googlemaps api in my android app using java?

I am new to android development but familiar with java. I want to send a request (containing coordinates of locations) to google maps api for distance matrix and later calculate the sum of distances for each point. The response from api is either in javascript or xml (i dont really know which one). How do i send the query in java and how do i extract the distances from the response?
Try using seperate classes to send and recieve data through the Google maps API. try using JSON to send aaplication data.
In order to use any thing like this (or that is owned by google etc.. ) You first need to setup a developer account at https://play.google.com/apps/publish/signup/
It does cost 25 dollars but in all honesty it's worth it as you get access to a lot of different things including the google maps api, if you're not interested in spending the $25 I would suggest looking into an alternative mapping api.
If on the other hand you will spend the money they've got some great tutorials laid out in the documentation!
A Google Maps Distance Matrix API request takes the following form:
https://maps.googleapis.com/maps/api/distancematrix/output?parameters
If you need more information, Refer to "Distance Matrix Requests".
https://developers.google.com/maps/documentation/distance-matrix/intro#DistanceMatrixRequests
You can also use the "getDistanceMatrix" that issues a distance matrix request.
https://developers.google.com/maps/documentation/javascript/3.exp/reference#DistanceMatrixService

Java - Multiple Destinations on Google Maps through URL

I am writing a program in Java that creates multiple destination points (latitude,longitude).
And I wish to add each destination as a marker on Google Maps.
The problem is, Google Maps doesn't allow more than 25 markers at a time.
At the moment I use I am creating a a URL string to represent the map, this is an example:
String url = "http://maps.google.com/maps?saddr=33.542550,-112.071399&daddr=33.538090,-112.047250+to:33.523892,-112.093669";
and then I call
java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
to open google maps with 3 markers present.
When my string includes more than 25 destination points, it does not work since Google maps does not allow it.
Are there any ways around this? and possible make 50 markers in one map?
Create your own map with the Google Maps Javascript API that supports as many markers as you want. Beware however of URL length limitations.
Another option would be to create a KML file containing your markers with a unique name and use that to display the markers.

get location based on image

I am trying to get the location (preferably city name) based on any image uploaded. I can see similar functionality used in Google image search where we drag drop an image and it gives a lot of information including location. Is there any API (or any other way) through which I can get similar sort of information? I have checked tineye but it requires commercial license so can't use that
I got a solution for this. Basically its using multiple google apis to get one result
Google Image Search API
call the JSON api https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=http://www.aparisguide.com/eiffeltower/eiffel-tower1.jpg
This will result json with information/content about image. We can use this content in step 2
Google Search api with the content or title obtained from previous search, try accessing google search api http://ajax.googleapis.com/ajax/services/search/local?v=1.0&q=Eiffel%20Towerthis will return the lat and lng for search results as JSON
Google geocode api with the available lat and lng from previous search we can call the geocode api as below http://maps.googleapis.com/maps/api/geocode/json?latlng=48.858228,2.294388&sensor=truethis will again return JSON with the list of possible address. With little processing of data it can give me the City.
Note: The results are not very consistent but it can solve the purpose to some extent

Get route points on Android using mapquest

I'm using mapquest java library for Android. Actualy I have simple android application with map and I can determine route between two locations. The thing I need to do is to get geopoints of this route. The code below is from samples of mapquest.
routeManager.setRouteCallback(new RouteManager.RouteCallback() {
public void onSuccess(RouteResponse routeResponse) {
clearButton.setVisibility(View.VISIBLE);
if (showItineraryButton.getVisibility() == View.GONE &&
showMapButton.getVisibility() == View.GONE) {
showItineraryButton.setVisibility(View.VISIBLE);
}
createRouteButton.setEnabled(true);
}
});
The routeResponse object has a serviceResponse field of jsonObject type. One of the elements of this jsonObject is field called "shapePoints". The documentation of the RouteResponse sais that routeResponse field should have an array of geopoints pairs. I'm not getting this array, but some kind of hashed string :/ :
"shapePoints":"gvxpjAfxthgEkF?cQ]yQ?umA?qMOog#Oej#?u|Ak#qv#OcLOoHiBcGwD_IoHiCkAoCOmFN_DjAyBhBaBhC}JpR??gToS_b#}_#oIaHee#{`#k_#c[eo#se#ce#q\\iHsEgh#q\\}m#__#_i#uY_IeEyWgNav#}_#cjAum#s~#sf#{[eOc[kLiMeE{JwCgTsFmd#oIuwAkVwiHqoAux#wNgh#oIuYuEqMiBuJ{AyLyB}JyB_SeEmPeEuSsFka#{Lse#wMsPeFcLwCqjAm^ey#mUuiD{_Akp#aReTaGoSuE{[sGm_#uDku#sFyL}#eJ{#eJ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xGoHbByCzEwMd#cG?cP?gc#?yk#{#kLcBcGVkK?kK?{`#??kB?"
Please help me with the funny shapePoints string, to get geopoints of the route. Maybe there is a different way to get those points. I was trying to google it for few days but without any bigger results ;/
The shapePoints string that you are seeing is actually a compressed format, so it is showing the shapePoints, but just not in a regular, readable raw format. The Android Maps API uses the MapQuest Directions Web Service for routing functions. The default routeResponse format in the Android API is cmp6, which is the compressed format that you are seeing, because it is generally more efficient to use the compressed format in an application.
You can tell the Directions Web Service to send the response back in a raw format by setting the shapeFormat parameter, which is included in the Directions Web Service documentation under the Advanced Routing Options section. Check out the Android Maps API Reference Guide for more specific information about setting the route options from within the Android Maps API -- look for the setOptions method on this page.
Also, just want to add that there is a Android Maps API forum on the MapQuest Developer Network and it is also a good resource to check when you have questions about the Android or other MapQuest APIs, like Flash, iOS, etc.
Please don't hesitate to ask if you need more assistance!

Categories

Resources