2016-12-09 4 views
0

私はボタンとTextViewがあるカスタムInfoWindowを作成しようとしていますが、そのボタンが機能していないので、クリックするとinfoWindow全体がクリックされます。 これは私のonReadyMap機能です:インタラクティブinfoWindow google map - android

public void onMapReady(GoogleMap map) { 
    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { 
     // TODO: Consider calling 
     // ActivityCompat#requestPermissions 
     // here to request the missing permissions, and then overriding 
     // public void onRequestPermissionsResult(int requestCode, String[] permissions, 
     //           int[] grantResults) 
     // to handle the case where the user grants the permission. See the documentation 
     // for ActivityCompat#requestPermissions for more details. 
     ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION}, 123); 
    } 
    else{ 

    LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 
    Criteria criteria = new Criteria(); 
    Location location = locationManager.getLastKnownLocation(locationManager.getBestProvider(criteria, false)); 
     // Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient); 
     if(location==null) 
     { 
      Toast.makeText(this,"erreur de connexion",Toast.LENGTH_SHORT); 
     } 
    if (location != null) 
    { map.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { 
     @Override 
     public View getInfoWindow(Marker marker) { 
      return null; 
     } 

     @Override 
     public View getInfoContents(Marker marker) { 
      View v = getLayoutInflater().inflate(R.layout.info_window,null); 
      TextView nomCompagnie = (TextView) v.findViewById(R.id.txt_infoWindow_compagnie); 
      TextView assurance = (TextView) v.findViewById(R.id.txt_infoWindow_assurance); 
      TextView dispo = (TextView) v.findViewById(R.id.txt_infoWindow_dispo); 
      TextView loca = (TextView) v.findViewById(R.id.txt_infoWindow_localisation); 
      Button notifier = (Button) v.findViewById(R.id.btn_infowindow_notif); 
      nomCompagnie.setText(marker.getTitle()); 
      LatLng latlng=marker.getPosition(); 
      loca.setText("("+latlng.latitude+","+latlng.longitude+")"); 

      return v; 
     } 
    }); 
     map.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { 
      @Override 
      public boolean onMarkerClick(Marker marker) { 
       Toast.makeText(getApplicationContext(),"clicked",Toast.LENGTH_SHORT).show(); 
       return false; 
      } 
     }); 
     map.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 13)); 
     map.addMarker(new MarkerOptions().position(new LatLng(location.getLatitude(), location.getLongitude())).title("Je suis ici !")).showInfoWindow(); 
     for(int i=0;i<arrayPosition.size();i++) 
     { 
      map.addMarker(new MarkerOptions().position(new LatLng(arrayPosition.get(i).getLatitude(), arrayPosition.get(i).getLongitude())).title("Je suis numéro "+i+"")).showInfoWindow(); 
      // Log.d("wiwwww", "heereee"); 
     } 
     CameraPosition cameraPosition = new CameraPosition.Builder() 
       .target(new LatLng(location.getLatitude(), location.getLongitude()))  // Sets the center of the map to location user 
       .zoom(12)     // Sets the zoom 
       .build();     // Creates a CameraPosition from the builder 
     map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); 
     map.setMyLocationEnabled(true); 

    }}} 

誰もが唯一のボタンをクリック可能にすることができます任意のアイデアを持っていますか? enter image description here

+1

これは完全に正常です。私が見ていないときにMaps V2で大きな変更が加えられていない限り、画面に表示されるのはあなたの情報ウィンドウの 'View'ではなく、' View'から生成される 'Bitmap'です。情報ウィンドウのインタラクティブなコンテンツはサポートされていません。 – CommonsWare

答えて

1

私はhereはあなたがあなたがやりたいthisライブラリを使用することができます.Moreover探しているものだと思います。

関連する問題