getting googlemaps to accept a local KML file?
I am trying to get googlemaps to accept a local KML file.
final Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("geo:0,0?q=file://" + Environment.getExternalStorageDirectory() + "/locate.kml"));
startActivity(myIntent);
The file is on the SD card, and is a valid kml file. Googlemaps loads up, but says it cannot find the file.
final Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("geo:0,0?开发者_StackOverflow社区q=http://www.website.com/locate.kml"));
startActivity(myIntent);
Works fine. geo:0,0?q= seems to be very under documented, can anyone help me out with how to use it to refer to a local file?
I think the problem is that when you try to open a URL using google maps, the application sends a search request to google using the url you provided.
Then google servers get the data from the url you have provided and return the result.
Since google servers cannot access urls like 'file://' or anything local like 'http://localhost' you get an error. That is the reason the second command works, google servers can access http://www.website.com/locate.kml
It seems it can't be done until Android 2.1
http://code.google.com/p/android/issues/detail?id=2454
JavaScript runs in a Sandbox, so it is not able to access local files without proprietary extensions.
精彩评论