-3

I'm trying to to implement a addProximityAlert when an info window is clicked

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

    public void addProximityAlert(double latitude, double longitude){


             LatLng clickedMarkerLatLng = marker.getPosition();
                    double lat =  clickedMarkerLatLng.latitude;
                    double long1 =  clickedMarkerLatLng.longitude;

                Log.e("hello", "Output=" + lat + long1);

                   LocationManager lm;
             //   double lat=123,long1=34;    //Defining Latitude & Longitude
                  float radius=30;                         //Defining Radius
            Intent intent = new Intent(PROX_ALERT_INTENT);
            PendingIntent proximityIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
            locationManager.addProximityAlert(
                lat, // the latitude of the central point of the alert region
                long1, // the longitude of the central point of the alert region
                POINT_RADIUS, // the radius of the central point of the alert region, in meters
                PROX_ALERT_EXPIRATION, // time for this proximity alert, in milliseconds, or -1 to indicate no expiration
                proximityIntent // will be used to generate an Intent to fire when entry to or exit from the alert region is detected
           );
           IntentFilter filter = new IntentFilter(PROX_ALERT_INTENT); 
           registerReceiver(new ProximityIntentReceiver(), filter);
        }
     }

});

This has "Java errors" and I'm unsure as to how to fix them. Apparently in line public void addProximityAlert(double latitude, double longitude){ the brackets and comma aren't necessary, despite them being needed. Can somebody help?

EDIT: OK, so I've implemented some of the answers below, but I'm still having problems. The getBroadcast method is undefined for the type InfoWindowClickListener. Any suggestions?

Jordan Moffat
  • 337
  • 6
  • 17

2 Answers2

0

You have two merged method declarations:

public void onInfoWindowClick(Marker marker) {

public void addProximityAlert(double latitude, double longitude){

Not sure what your intent is, but you need to close off the declaration of onInfoWindowClick(Marker marker) before beginning the declaration of addProximityAlert

Chris Knight
  • 24,333
  • 24
  • 88
  • 134
  • The intent is to call the `addProximityAlert` method when the info window is clicked. I also need to pass the parsed longitude and latitude variables to the `addProximityAlert` method – Jordan Moffat Mar 18 '13 at 07:27
0

Try it like this:

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

                        addProximityAlert(latitude,longitude);
         }

    });

 public void addProximityAlert(double latitude, double longitude){


         LatLng clickedMarkerLatLng = marker.getPosition();
                double lat =  clickedMarkerLatLng.latitude;
                double long1 =  clickedMarkerLatLng.longitude;

            Log.e("hello", "Output=" + lat + long1);

               LocationManager lm;
         //   double lat=123,long1=34;    //Defining Latitude & Longitude
              float radius=30;                         //Defining Radius
        Intent intent = new Intent(PROX_ALERT_INTENT);
        PendingIntent proximityIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
        locationManager.addProximityAlert(
            lat, // the latitude of the central point of the alert region
            long1, // the longitude of the central point of the alert region
            POINT_RADIUS, // the radius of the central point of the alert region, in meters
            PROX_ALERT_EXPIRATION, // time for this proximity alert, in milliseconds, or -1 to indicate no expiration
            proximityIntent // will be used to generate an Intent to fire when entry to or exit from the alert region is detected
       );
       IntentFilter filter = new IntentFilter(PROX_ALERT_INTENT); 
       registerReceiver(new ProximityIntentReceiver(), filter);
    }
Amitabh Sarkar
  • 1,281
  • 1
  • 13
  • 26