Google地图链接按符号划分

时间:2014-04-03 20:05:05

标签: android gps sms location maps

我正在为我的学校开发紧急申请,我有一个问题。我有代码获取您的坐标,而smsmanager将它们发送到指定的电话号码。我尝试将坐标放在Google地图链接中,以便收件人只需点击链接而不是将坐标输入到Google地图中,但是当我这样做时,链接会被“=”,“<”打破和“>”迹象。我想知道我能在代码中做些什么来使链接工作。当收件人收到邮件时,它看起来像这样..

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() + ">");

}

1 个答案:

答案 0 :(得分:0)

尝试:

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");

当您使用Google地图时,地址应自动更新,尝试一下,看看它是如何变化的。