通过Intent打开Goog​​le Map并在某个纬度经度中添加标记

时间:2016-02-25 10:02:22

标签: android google-maps google-maps-markers

我的应用通过ACTION.VIEW意图打开谷歌地图。当我只给出纬度和经度时,地图会显示没有标记的区域。为了获得标记,我使用了以下代码,

Uri uri = Uri.parse("geo:"+Double.parseDouble(dealer_lat)+","+Double.parseDouble(dealer_long)+"?q="+Uri.encode(dealer_nameX+", "+provider_location.toLowerCase()+","+provider_street.toLowerCase()));
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setPackage("com.google.android.apps.maps");
startActivity(intent);

但是这段代码通过我提供的地址搜索位置。 我需要将标记添加到latLng给出的位置,同时还显示带有特定文本的标记标签。 我该怎么办?

1 个答案:

答案 0 :(得分:0)

   String uri = "http://maps.google.com/maps?f=d&hl=en&saddr=" + geoPoint.getLatitude() + "," + geoPoint.getLongitude() + "&daddr=" +
                trip.getPickupLocation().getLatitude() + "," + trip.getPickupLocation().getLongitude();

        Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
        startActivity(Intent.createChooser(intent, "Select an application"));