我想点击mapv2上的图钉分享位置。我已经在按下引脚上实现弹出窗口,但不知道位置共享。 所以任何人都可以在其中实施..
ButtonListener = new PopupWindowTouchListener(popupButton) {
@Override
protected void onClickConfirmed(View v, Marker marker) {
// Toast.makeText(MainActivity.this, "button1 clicked!", Toast.LENGTH_SHORT).show();
String message = "http://maps.google.com/maps?q=" + latitude + "," + longitude + "&iwloc=A";
System.out.println("message...> " + message);
sendSMS("**********",message);
}
};
private void sendSMS(String phoneNumber, String message){
System.out.println("message..> " + message);
System.out.println("phoneno..> " + phoneNumber);
SmsManager sms = SmsManager.getDefault();
Log.d("TAG", "Attempting to send an SMS to: " + phoneNumber);
try {
sms.sendTextMessage(phoneNumber, null, message, null, null);
System.out.println("successfully sent ");
} catch (Exception e) {
Log.e("TAG", "Error sending an SMS to: " + phoneNumber + " :: " + e);
}
}
答案 0 :(得分:1)
Marker.getPosition()
将返回LatLng
LatLng latlng = Marker.getPosition();
Double latitude = latlng.latitude;
Double longitude = latlng.longitude;
您可以操纵latitude
和longitude
值来构建数据格式。并使用Intent chooser分享。
例如 "http://maps.google.com/maps?q=" + latitude + "," + longitude + "&iwloc=A"
并通过SMS分享
答案 1 :(得分:0)
String uri = "http://maps.google.com/maps?saddr=" +latitude+","+longitude;
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String ShareSub = "Here is my location";
sharingIntent.putExtra(Intent.EXTRA_SUBJECT, ShareSub);
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, uri );
startActivity(Intent.createChooser(sharingIntent, "Share via"));