开发者

What's the secret to hosting custom KML for use in Google Maps Mobile?

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 tool开发者_如何学Cs are available (if any) to determine what is wrong with what I've done (something more informative than "The community map...")?

Thanks


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜