views:

55

answers:

1

I am new to Android and so I may be missing some very basic things here.

I am trying to host custom KML files on a server behind my firewall and display those KML files on the Android emulator.

I started by writing a simple app that uses an Intent to display the overlay and pointing the app at geo:0,0?q=http://code.google.com/apis/kml/documentation/KML_Samples.kml. This works in the emulator.

Next I downloaded that KML file and posted it on my web server (Apache 2.2 on Fedora). I added an AddType directive for the .kml extension and restarted HTTPD.

When I point my simple app's Intent to my internally hosted KML file I get the error "The community map could not be displayed because it contains errors."

I added some code to try and download the KML file independently of the KML so I could check the status line and the like:

final HttpClient client = new DefaultHttpClient();
final HttpGet get = new HttpGet("http://mycompany.com/data/KML_Samples.kml");
try {
    final HttpResponse resp = client.execute(get);
    android.util.Log.e("MapOverlays", resp.toString());
} catch (Throwable t) {
    android.util.Log.e("MapOverlays", "Exception", t);
}

With a breakpoint on the first Log message line I can inspect the results:

statusline = "HTTP/1.1 200 OK"

Content-Type: application/vnd.google-earth.kml+xml

Here's the Intent I'm using:

final Intent intent = new Intent(
android.content.Intent.ACTION_VIEW,
        Uri.parse("geo:0,0?q=http://mycompany.com/data/KML_Samples.kml"));
startActivity(intent);

So the two main questions are

  1. What do I need to do to get KML loaded from a private server?
  2. What tools are available (if any) to determine what is wrong with what I've done (something more informative than "The community map...")?

Thanks

A: 

These may be silly questions, but I need to know whether you have verified that the KML file in question is in fact valid KML.

Another problem that you may have is that the KML file you are downloading contains network links which are themselves not reachable from your Android device.

jjrdk
I had assumed that the KML was valid as I downloaded a copy from the Google site and posted it to my own web server.I'll have to dig through it to see if there are any external links, but if there were, then wouldn't both have failed?
Josh
The reason I asked was that the error message seemed unrelated to your application. From your network info it looks like it is in fact getting the KML file (is it? Have you checked the response length?) then the errors I could think of would be related to malformed KML.
jjrdk