Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何将经纬度发送到地图应用程序以在地图上显示特定坐标?_Android_Google Maps - Fatal编程技术网

Android 如何将经纬度发送到地图应用程序以在地图上显示特定坐标?

Android 如何将经纬度发送到地图应用程序以在地图上显示特定坐标?,android,google-maps,Android,Google Maps,我有一个应用程序,在其中单击一个按钮,或更改位置,或在特定时间之后,我能够获得经度和纬度值。我想用这个值在谷歌地图应用程序上显示它们。我打开一张地图,意图显示位置,但不知何故,它并没有显示我得到的坐标 Double latitud = 37.40*1E6; Double longitud = -5.99*1E6; GeoPoint loc = new GeoPoint(latitud.intValue(), lon

我有一个应用程序,在其中单击一个按钮,或更改位置,或在特定时间之后,我能够获得经度和纬度值。我想用这个值在谷歌地图应用程序上显示它们。我打开一张地图,意图显示位置,但不知何故,它并没有显示我得到的坐标

Double latitud = 37.40*1E6;
            Double longitud = -5.99*1E6;

            GeoPoint loc =
                new GeoPoint(latitud.intValue(), longitud.intValue());

            controlMapa.animateTo(loc);

            int zoomActual = mapa.getZoomLevel();

            for(int i=zoomActual; i<10; i++)
                controlMapa.zoomIn();
        }
有关更多信息:


更多信息:

这是我在一个应用程序中使用的一段工作代码。此代码还包括一项检查,以确定用户的设备上是否安装了谷歌地图。如果检查返回已安装的应用程序,则函数将数据传递给应用程序。如果检查失败,它将显示一个AlertDialog,通知用户未安装应用程序

protected void showMap() {

    boolean installedMaps = false;

    // CHECK IF GOOGLE MAPS IS INSTALLED
    PackageManager pkManager = getPackageManager();
    try {
        @SuppressWarnings("unused")
        PackageInfo pkInfo = pkManager.getPackageInfo("com.google.android.apps.maps", 0);
        installedMaps = true;
    } catch (Exception e) {
        e.printStackTrace();
        installedMaps = false;
    }

    // SHOW THE MAP USING CO-ORDINATES FROM THE CHECKIN
    if (installedMaps == true) {
        String geoCode = "geo:0,0?q=" + PLACE_LATITUDE + ","
                + PLACE_LONGITUDE + "(" + PLACE_NAME + ")";
        Intent sendLocationToMap = new Intent(Intent.ACTION_VIEW,
                Uri.parse(geoCode));
        startActivity(sendLocationToMap);
    } else if (installedMaps == false) {

        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                CheckinsDetails.this);

        // SET THE ICON
        alertDialogBuilder.setIcon(R.drawable.ic_launcher);

        // SET THE TITLE
        alertDialogBuilder.setTitle("Google Maps Not Found");

        // SET THE MESSAGE
        alertDialogBuilder
                .setMessage(R.string.noMapsInstalled)
                .setCancelable(false)
                .setNeutralButton("Got It",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                dialog.dismiss();
                            }
                        });

        // CREATE THE ALERT DIALOG
        AlertDialog alertDialog = alertDialogBuilder.create();

        // SHOW THE ALERT DIALOG
        alertDialog.show();
    }
}
下面提到的这行代码将其发送到Google Maps,并且不仅显示Pin,还显示位置名称

String geoCode = "geo:0,0?q=" + PLACE_LATITUDE + ","
                    + PLACE_LONGITUDE + "(" + PLACE_NAME + ")";
编辑:如果不希望显示地名,请使用:
geo:latitude,longitude
修改该特定行,而不是代码块中使用的行


查看此链接以了解更多可能的组合,例如缩放:

这是我在一个应用程序中使用的一段工作代码。此代码还包括一项检查,以确定用户的设备上是否安装了谷歌地图。如果检查返回已安装的应用程序,则函数将数据传递给应用程序。如果检查失败,它将显示一个AlertDialog,通知用户未安装应用程序

protected void showMap() {

    boolean installedMaps = false;

    // CHECK IF GOOGLE MAPS IS INSTALLED
    PackageManager pkManager = getPackageManager();
    try {
        @SuppressWarnings("unused")
        PackageInfo pkInfo = pkManager.getPackageInfo("com.google.android.apps.maps", 0);
        installedMaps = true;
    } catch (Exception e) {
        e.printStackTrace();
        installedMaps = false;
    }

    // SHOW THE MAP USING CO-ORDINATES FROM THE CHECKIN
    if (installedMaps == true) {
        String geoCode = "geo:0,0?q=" + PLACE_LATITUDE + ","
                + PLACE_LONGITUDE + "(" + PLACE_NAME + ")";
        Intent sendLocationToMap = new Intent(Intent.ACTION_VIEW,
                Uri.parse(geoCode));
        startActivity(sendLocationToMap);
    } else if (installedMaps == false) {

        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                CheckinsDetails.this);

        // SET THE ICON
        alertDialogBuilder.setIcon(R.drawable.ic_launcher);

        // SET THE TITLE
        alertDialogBuilder.setTitle("Google Maps Not Found");

        // SET THE MESSAGE
        alertDialogBuilder
                .setMessage(R.string.noMapsInstalled)
                .setCancelable(false)
                .setNeutralButton("Got It",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog,
                                    int id) {
                                dialog.dismiss();
                            }
                        });

        // CREATE THE ALERT DIALOG
        AlertDialog alertDialog = alertDialogBuilder.create();

        // SHOW THE ALERT DIALOG
        alertDialog.show();
    }
}
下面提到的这行代码将其发送到Google Maps,并且不仅显示Pin,还显示位置名称

String geoCode = "geo:0,0?q=" + PLACE_LATITUDE + ","
                    + PLACE_LONGITUDE + "(" + PLACE_NAME + ")";
编辑:如果不希望显示地名,请使用:
geo:latitude,longitude
修改该特定行,而不是代码块中使用的行

检查此链接以了解更多可能的组合,例如缩放:

尝试以下操作:

String url = "http://maps.google.com/maps?daddr="+ ze.getCoordenada().getLatitude() + ","+     ze.getCoordenada().getLongitude();
Intent goZe = new Intent(Intent.ACTION_VIEW);
goZe.setData(Uri.parse(url));
startActivity(goZe);
您将收到使用浏览器或地图的提示,请尝试以下操作:

String url = "http://maps.google.com/maps?daddr="+ ze.getCoordenada().getLatitude() + ","+     ze.getCoordenada().getLongitude();
Intent goZe = new Intent(Intent.ACTION_VIEW);
goZe.setData(Uri.parse(url));
startActivity(goZe);

在google上使用此字符串,您将得到一个使用浏览器或地图的提示

String url = "http://maps.google.com/maps?daddr="+ ze.getCoordenada().getLatitude() + ","+     ze.getCoordenada().getLongitude();
选择谷歌地图时,会显示网站的经度和纬度,而网站是正确的


也许我正在使用谷歌地图的旧版本,在谷歌上使用这个字符串

String url = "http://maps.google.com/maps?daddr="+ ze.getCoordenada().getLatitude() + ","+     ze.getCoordenada().getLongitude();
public void showMap(long latitude, long longitude) {
    String geoCode = "geo:0,0?q=" + latitude + ","
                        + longitude;
    Intent sendLocationToMap = new Intent(Intent.ACTION_VIEW, Uri.parse(geoCode));
    if (sendLocationToMap.resolveActivity(getPackageManager())!=null){
        startActivity(sendLocationToMap);
    }
    else {
        Toast.makeText(this,"No Application To handle the Request",Toast.LENGTH_SHORT).show();
    }
}
选择谷歌地图时,会显示网站的经度和纬度,而网站是正确的


也许我使用的是谷歌地图的旧版本

我没有为显示地图编写代码,但想将坐标发送到现有的地图应用程序,我们在evry android mobile上获得了该应用程序……,“是的,我知道。。。。controlMapa.animateTo(loc);当loc处于位置时。。。。它的代码与@Siddharth Lele相同,但更简单。。。由你们决定……我并没有为显示地图编写代码,但我想将坐标发送到现有的地图应用程序,我们在evry android mobile上获得了该应用程序……是的,我知道。。。。controlMapa.animateTo(loc);当loc处于位置时。。。。它的代码与@Siddharth Lele相同,但更简单。。。由你决定……@PrashantRane:很高兴能帮上忙。:-)@PrashantRane:很高兴能帮上忙。:-)
public void showMap(long latitude, long longitude) {
    String geoCode = "geo:0,0?q=" + latitude + ","
                        + longitude;
    Intent sendLocationToMap = new Intent(Intent.ACTION_VIEW, Uri.parse(geoCode));
    if (sendLocationToMap.resolveActivity(getPackageManager())!=null){
        startActivity(sendLocationToMap);
    }
    else {
        Toast.makeText(this,"No Application To handle the Request",Toast.LENGTH_SHORT).show();
    }
}