0

マーカーを選択し、情報ウィンドウをクリックして確認することで、ユーザーが近接アラームを設定できるアプリを構築しています。座標を使用して半径を設定できるように、マーカーから緯度と経度を取得できる必要があります。

 googleMap.setOnInfoWindowClickListener(
   new OnInfoWindowClickListener(){
     public void onInfoWindowClick(Marker marker) {

         //click function
      Toast.makeText(getBaseContext(), 
        "Info Window clicked@" + marker.getPosition(), 
        Toast.LENGTH_SHORT).show();

     LocationManager lm;
     double lat=0;
     double long1=0;    //Defining Latitude & Longitude
     float radius=3000;

    lm=(LocationManager) getSystemService(LOCATION_SERVICE);
    Intent i= new Intent("com.example.sleepertrain5.proximityalert");           //Custom Action
    PendingIntent pi = PendingIntent.getBroadcast(getApplicationContext(), -1, i, 0);
    lm.addProximityAlert(lat, long1, radius, -1, pi);

これまでのところ、marker.getLocation()変数を直接設定できないものしか見つけられませんでした。これを行う方法はありますか?

4

2 に答える 2

0

このコードがお役に立てば幸いです:

@Override
public void onMapLongClick(LatLng point) {

Latitude lat = point.getLatitude(); 
Longitude lng = point.getLongitude();

}
于 2013-03-17T19:33:06.603 に答える
0

これを試しましたか:

map.setInfoWindowAdapter(new InfoWindowAdapter() {

// Use default InfoWindow frame
@Override
public View getInfoWindow(Marker args) {
    return null;
}

// Defines the contents of the InfoWindow
@Override 
public View getInfoContents(Marker args) 
{
    LatLng clickedMarkerLatLng = args.getPosition();
    double latitude =  clickedMarkerLatLng.latitude;
    double longitude =  clickedMarkerLatLng.longitude;
    ....
}
于 2013-03-17T18:45:26.327 に答える