问题
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?
回答1:
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
回答2:
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);
}
来源:https://stackoverflow.com/questions/15471594/java-errors-in-android-app