【问题标题】:Google Maps Link Broken By Symbols谷歌地图链接被符号破坏
【发布时间】:2014-05-15 21:16:00
【问题描述】:

我正在为我的学校开发一个紧急应用程序,我有一个问题。我有获取您坐标的代码,smsmanager 将它们发送到指定的电话号码。我试图将坐标放在谷歌地图链接中,以便收件人只需单击链接而不是将坐标输入谷歌地图,但是当我这样做时,链接被“=”、“”破坏迹象。我想知道我可以在我的代码中做些什么来使链接工作。当收件人收到消息时,它看起来像这样..

"http://maps.google.com/?q"=,

引号中的所有内容都是链接,其余的都不是。

public void onClick(View v) {

try {

                    txtLat = (TextView) findViewById(R.id.textview1);
                    String messageToSend = txtLat.getText().toString();
                    String number = "8143664050";
                    SmsManager.getDefault().sendTextMessage(number, null, messageToSend, null,null);

                    Toast.makeText(getApplicationContext(), "Help SMS Sent",
                            Toast.LENGTH_LONG).show();


                } catch (Exception e) {
                    Toast.makeText(getApplicationContext(), "SMS failed!",
                            Toast.LENGTH_LONG).show();
                    e.printStackTrace();
                }
            }
        });
    }

}

@Override
public void onLocationChanged(Location location) {
    txtLat = (TextView) findViewById(R.id.textview1);
    txtLat.setText("http://maps.google.com/?q=<" + location.getLatitude() + ">,<" + location.getLongitude() + ">");

}

【问题讨论】:

    标签: android gps sms location maps


    【解决方案1】:

    尝试:

    int zoom = 12;
    txtLat.setText(
            "https://www.google.com/maps/@" + location.getLatitude() + "," + 
            location.getLongitude() + "," + zoom + "z");
    

    对于 3d/卫星地图:

    txtLat.setText(
            "https://www.google.com/maps/@" + location.getLatitude() + "," + 
            location.getLongitude() + ",15000m/data=!3m1!1e3");
    

    当您使用谷歌地图时,地址应该会自动更新,试试看它是如何变化的。

    【讨论】:

    • 还有一个小问题。例如,有没有办法可以将地图类型从这里更改为卫星?
    猜你喜欢
    • 2018-12-30
    • 1970-01-01
    • 1970-01-01
    • 2012-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多