Android: getting invalid KML file from Google maps

I am trying to get and display a live.kml file from maps.google.com using

Uri.parse("geo:0,0?q=http://maps.google.com/maps/ms?ie=UTF8&hl=en&msa=0&msid=104538451667315338387.0004887d133ba2ab6eec9&ll=42.029611,-93.646109&spn=0.011396,0.022724&z=16l&output=kml");

Intent mapIntent = new Intent(Intent.ACTION_VIEW, mapUri);

startActivity(Intent.createChooser(mapIntent, "lol"));

However, after opening mapview, I get a notification that "The community map cannot be displayed because it contains errors"

I get this error only if I download .kml directly from maps.google. If I copy the same link to my address bar, upload the .kml file and upload it to another location, then it works fine. I would like to be able to receive maps directly from Google so I can make changes and this will be immediately reflected to my users.

+3
source share
4 answers

I had the same problem - if you use "&" as the parameter separator, Google Maps for Android disables the URL, so use "% 26" instead:

Intent navigateToIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(
    "geo:0,0?q=http://m.konzoomer.com/kml?id=" + id +
    "%26latitudeE12=" + latitudeE12 + "%26longitudeE12=" + longitudeE12 +
    "%26radiusMeters=" + radiusMeters));
+2
source

try to display the downloaded Android data as text somewhere (i.e. via System.out.println), maybe it contains a description of the google error message

+1
source

, , . , , , & output = kml . - URL, google, .

This is far from an elegant solution, because I rely on both Google Maps and my URL to work to get the KML file on the user's phone. If any of them does not work, my system will not work.

I am open to other options and will change my answer if another arises.

+1
source

What if you create an intent with just a simple maps.google.com link without "& output = kml"?

0
source

Source: https://habr.com/ru/post/1749080/


All Articles