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.
Related
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.
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.
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
I am building the prototype for an Android app that should result in a versatile map that can deal with a large but static amount of environmental data combined with (user-generated) data that will be hosted on a separate platform.
My current approach is to fetch the large static data via Google Fusion Tables (in original a shape file - .shp, .dbf, .shx that I have exported as a .kml with QGisMaps - the "smaller" .kml I am using is already 66.4MB, the one intended for final use over 140 MB...) I know it is possible to slice down .kml but will this have an effect on loading times?
You can see a current example of the shape data on Google Maps here https://www.google.com/fusiontables/DataSource?snapid=S717313eWaJ
But now I am wondering if I am on the right path at all since this one layer of data is loading very slowly on my machine and I am not aware of the hassle to put this map into an Android app - and more importantly also fetching more data from a separate server and putting it as another (filterable) layer on top of it. This layer will be collected data from users, thus not "static" but regularly updated - integer values displayed in color per geodata.
Several people hinted me to use Open Street Maps but some advised that Android is very eloquent with Google Maps - in the middle of development I thought maybe someone can tell me whether I chose the right direction to go for or are most likely facing less problems with an alternative solution.
I would be really glad if someone could advise me on the issue with combining map data from two different sources layerd onto one map in Android whereas one bunch of data is huge but static and the other user-generated values.
Thanks so much for your time and looking over this
best
Birgit
EDIT #1: I am now switching to Open Street Maps, hoping to be able to set up a GeoServer myself hosting the data and querying the WMS with the App. It seems like the size of the data still has to be compressed in some way, I will keep you updated.
I'll not be able to address all of your concernes, but I can share some of my experience with maps and ovelays.
The most important concept you must be aware is the memory heap. Each android application has a maximum memory amount that can be used to allocate data objects, called memory heap. This limit is different from device to device and can go from 16MB in small older devices to 64MB in new tablets.
Having said that, you will never be able to load all your data at one shot if the data structure required to hold it exceeds the maximum heap available for the application.
Also, usaging large amounts of memory makes your application better candidate to be terminated by users or by the SO when additional memory is required by critical activities (like a phone call).
Now, going to the maps part...
I've used Google maps as well as mapsforge api for OpenStreet maps. Google maps requires internet connection, while mapsforge enables you to use a local map file or online connection. OpenStree maps don't provide the sattelite view.
Regarding performance, online connection tends to be faster, as they download already rendered map images, while offline map requires the images to be rendered as needed. Mapforges can use a local cache to improve this a little.
Displaying Overlays:
I've used both API's to display paths with arround 10.000 points over a map, together with additional overlays (compass, scale bar, pop-ups, etc.) and the code runs smoothly in a mid-rande device. However, my code have some optimizations to reduce recreation of paths (when user zoom or move map) by transforming the already existing path.
good luck.
So this is how I eventually converted a .shp file into a format that could be displayed by OSMdroid's XYTilesource.
I exported the layers separately as .kml projected WGS84 and imported them as layers to TileMill. After having defied the colors for each layer in CSS, I exported my map as a set of MBTiles. I uploaded them to Mapbox.com. From there I can fetch the tiles which are in the format a.tiles.mapbox.com/v3/myUsername.myTiles/{z}/{x}/{y}.png in my OSMdroid Mapview.
final myTileSource tileSource = new XYTileSource("myTiles", null, 10, 16, 256, ".png", "http://a.tiles.mapbox.com/v3/myUserName.myTiles/");
I am developing an Android application and would like to play a recorded track in DDMS tool. Besides latitude and longitude, my recorded data has horizontal accuracy which I'd like to pass to Android phone simulator.
Is there a way to specify accuracy in GPX or KML formats?
In neither of those specs is a named element for accuracy. Both however allow for extended data which where you can put whatever you want.
In GPX it's called 'extensions' See http://www.topografix.com/GPX/1/1/#type_extensionsType
In Kml it's called 'ExtendedData' See http://code.google.com/intl/nl-NL/apis/kml/documentation/kmlreference.html#placemark
As Eddy noted, there are no tags for accuracy.
But, GPX have something similar -- tags for dilution of precision (hdop, vdop, pdop) for every track point, waypoint or route point. Those are not exactly the same as "accuracy", but it can be used as such. See wikipedia for more.