Google Drive url
Hello, I want to display a kml file's layer, from url (from resource works well!) using those two functions of the api :
private void retrieveFileFromUrl() {
new DownloadKmlFile(getString(R.string.kml_url)).execute();
}
` protected byte[] doInBackground(String... params) { try { InputStream is = new URL(mUrl).openStream(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); int nRead; byte[] data = new byte[16384]; while ((nRead = is.read(data, 0, data.length)) != -1) { buffer.write(data, 0, nRead); } buffer.flush(); return buffer.toByteArray(); } catch (IOException e) { e.printStackTrace(); } return null; }
protected void onPostExecute(byte[] byteArr) {
try {
KmlLayer kmlLayer = new KmlLayer(mMap, new ByteArrayInputStream(byteArr),
getApplicationContext());
kmlLayer.addLayerToMap();
kmlLayer.setOnFeatureClickListener(new KmlLayer.OnFeatureClickListener() {
@Override
public void onFeatureClick(Feature feature) {
Toast.makeText(KmlDemoActivity.this,
"Feature clicked: " + feature.getId(),
Toast.LENGTH_SHORT).show();
}
});
moveCameraToKml(kmlLayer);
} catch (XmlPullParserException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
} `
well those two functions worked for the direct url used in the demo : " http://googlemaps.github.io/kml-samples/morekml/Polygons/Polygons.Google_Campus.kml "
but don't work for Google drive url! what should i change ?
I'm not sure what the solution is, but I'll close this for now since it isn't an issue specific to this library.
Might be worth posting to stackoverflow.com for better coverage.