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

你有没有试过这个:

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 回答
0

我希望这段代码可以帮助你:

@Override
public void onMapLongClick(LatLng point) {

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

}
于 2013-03-17T19:33:06.603 回答