简体   繁体   中英

Flying to lat/lon with Google Earth Android intent

I'm using the following code to fly to a specific latitude and longitude using a Google Earth Android intent:

Intent myIntent = new Intent(); 

myIntent.setClassName("com.google.earth", "com.google.earth.EarthActivity"); 
myIntent.setAction(Intent.ACTION_SEARCH); 
myIntent.putExtra(SearchManager.QUERY, lat + " " + lon);

This works pretty much OK, except that it seems to want to geocode the lat/lon to the nearest address, if one is within a certain range. That is, if the lat/lon is in the middle of Antarctica, the map centers on the given point, but if the coordinates are, say, of the Sphinx, the map centers on an address on Cairo Alex Desert Rd., some distance away.

Is there a way to make Google Earth for Android just go to the given lat/lon in all cases?

Try this:

Uri uri = Uri.parse("geo:38.899533,-77.036476");
Intent it = new Intent(Intent.Action_VIEW,uri);
startActivity(it);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM