Path between two very far points on google map in android - android

I am trying to develop very basic GPS App and want to highlight path between two cities. I used the code in the following post
Answer : Draw path between two points using Google Maps Android API v2
by zeeshan0026.
And the code works fine but when you highlight path between two very far cities then it shows the straight kind of path. I think the problem with the number of LatLng points return by the decodepoly function i am trying to change the shift but nothing helps.
Please somebody help me in this regard.
Thanks in Advance

Directions API URLs are restricted to approximately 2000 characters, after URL Encoding. As some Directions API URLs may involve many locations along a path, be aware of this limit when constructing your URLs.
For more accurate path between very far cities, we need to use the polyutil.encode and decode functions.

Related

How to connect Kml layer + Autocomplete in Kotlin Android?

I have a question about SDK Google maps in Android
I have a Autocomplete Place that works perfectly. When i write some text in the input, google show me locations, and when i click on any print coordinates.
Question:
Is there any way to know if those coordinates are in a polygon of a Google my maps kml file?
I tried:
KmlLayer(map,id for local file, context)
Documentation: https://developers.google.com/maps/documentation/android-sdk/utility/kml
The problem is that i need the local kml file on my local repository. I need to get KML file from URL with a map id (https://www.google.com/maps/d/u/0/viewer?mid=XXXXrsxRFHqpMEmYXXXXX)
That "mid", can change, since sometimes I will need to use another kml file with a different url.
Also, Autocomplete documentation: https://developers.google.com/maps/documentation/places/android-sdk/autocomplete
Thank you everyone.
Any help would be greatly appreciated! Thanks

Google static maps api for long route is not working

I am trying to show path between 2 different locations via google static maps api.
It's working for short distance.
But Poly line is not able to draw for long distances may be due to delimit of Url parameters.
How can I make it work for long distances?
Here is Working Example for Ahmedabad to Mumbai:
Here is Not Working Example for Ahmedabad to Goa:
You should reduce the points you get for the path. There special mathematical algorithms that will do it without losing any quality in viewing the path, especially on a higher zoom level. In the next step, you can encode the path-points.
I think all you need you can find in this discussion: Static Maps: Drawing polygons with many points. (2048 char limitation)
More you can find if you search for "simplify path" and maybe "encode Path".
Good Luck, Reinhard
PS.: Under GPSies.com you can plan a path, save and download it with different levels of reduced path-/trackpoints. Maybe you can use it for testing.

Is it possible to get a list of all zip codes that your driving directions pass through?

I'm looking (and not finding) any reference in the google maps api (both Android and Web) to get a list of all the zip codes that a given driving path moves through.
Am I overlooking this or is this not something that the API supports?
So, to be clear, I have directions from point A to point B and I'm interested in pulling up all the unique zip codes that the path goes through (not just the zip codes of the individual points where navigation instructions are given, but ALL zip codes for the entire path).
Why the zip codes? of all things? The zip code in the US only represents a very small portion of an address. Also, most people don't know zip codes, a more useful piece of information would be the city/county a car is driving through. Are you from outside the United States by any chance? Or are you making an application for postal workers?
In any case, what you're looking for is reverse geocoding. See this example of reverse geocoding on Google Maps.You give it a longitude and latitude and the server sends you back an address with the zip code included (for your purpose, you'll just need to disregard the rest of the information it gives you). This will have to be done on a point by point basis. There is nothing in the documentation I just linked to, that does this for an entire path.
If I were you, I'd go directly to the source, the census bureau. That's where Google Maps takes its address data from anyway.
Zip codes tend to be irregular in their shape in size (from covering large portions of towns to just a single floor of an office block).
Google does not appear to provide a facility to get the unique zip codes that your route passes through but you could certainly try and query (reverse geocoding for a lat-long coordinate) every x meters along your route to get a (near) complete list.
When you request directions you get a directionResult object which contains many DirectionLeg objects, which contains DirectionStep objects which have a lat-lng for their path. If the lat-lngs are too far apart you can interpolate, if they are two close you can skip some.

retrieving the maxspeed tag in openstreetmap

I want to create an android application that warns me if I am to exceed the speed limit, and I thought of using the maxspeed tag in openstreetmaps , but when I got the data using the API I can't find the speedmax tag but it's there when I lookup the place in the site. is there any other way to retreive the max speed limit for each road to use it in my app ?
You are searching for the maxspeed=* tag http://wiki.openstreetmap.org/wiki/Key:maxspeed (query taginfo on right sidebar)
Furhtermore there are different solutions for your task:
Ask existing map creators on help/data (lookup "Maps" in OSM Wiki)
Create a query for the Overpass API maybe helpful is Overpass Turbo
Filter OSM Planet extracts on your own using osmosis and appropriate filter expressions
Please keep in mind, that dealing with OSM data can be difficult, as for example speed units depend on the country, same as defaults for untagged roads.
P.S. It's called OpenStreetMap (without -s) ;)
http://www.overpass-api.de/api/xapi?[maxspeed=][bbox=31.454403,30.082119,31.454266,30.082093]
just use two points (LAN/LAT) on the same road to get the road details

Can I always keep some static Markers in Android Map?

I'm a newbie into Android programming... Here's what I'm trying to do for a small academic project:
A google map displayed on screen: Done
Get user's current location and show on the map: Done
We've a list of Latitudes and Longitudes coming from a webservice, which forms a pre-defined path. I need to display an always-shown path on the map with static markers as per the list of Lat-Longs given. How?
I tried various ways, and searched various places, but couldn't find a satisfactory code or tutorial that has achieved the same. Can someone please point me to an appropriate resource that I can use to get the above?
Download and check for static marker..................
https://github.com/commonsguy/cw-android/tree/master/Maps/NooYawk
http://android-codes-examples.blogspot.com/2011/04/google-map-example-in-android-with-info.html
You need to implement Overlay and draw the path in the draw() method.
Use this SO post to get an idea of how to do it.

Categories

Resources