I wan to execute a Infowindow with button, its execute nicely. I use this, where I found on github.
But, if I try to put GeoJson layer on it, the button is disapear
I try many way to make this error gone, but I still facing problem with this.
This Error I found, the button is disapear
This is what I want, with GeoJson layer on it
Here's my Main Activity
ublic void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(CILACAP, 10f));
mapWrapperLayout = (MapWrapperLayout)findViewById(R.id.map_relative_layout);
// MapWrapperLayout initialization
// 39 - default marker height
// 20 - offset between the default InfoWindow bottom edge and it's content bottom edge
mapWrapperLayout.init(mMap, getPixelsFromDp(this, 39 + 20));
// We want to reuse the info window for all the markers,
// so let's create only one class member instance
this.infoWindow = (ViewGroup)getLayoutInflater().inflate(R.layout.custom_info_window, null);
this.infoTitle = (TextView)infoWindow.findViewById(R.id.title);
this.infoSnippet = (TextView)infoWindow.findViewById(R.id.snippet);
this.infoButton = (Button)infoWindow.findViewById(R.id.button);
// Setting custom OnTouchListener which deals with the pressed state
// so it shows up
this.infoButtonListener = new OnInfoWindowElemTouchListener(infoButton,
getResources().getDrawable(R.drawable.button_normal),
getResources().getDrawable(R.drawable.button_pressed)) {
@Override
protected void onClickConfirmed(View v, Marker marker) {
// Here we can perform some action triggered after clicking the button
//Toast.makeText(MainActivity.this, "Tombol " + marker.getTitle() + " di click!", Toast.LENGTH_SHORT).show();
Intent pdf = new Intent(MainActivity.this, showPdf.class);
pdf.putExtra("title", marker.getTitle());
startActivity(pdf);
}
};
this.infoButton.setOnTouchListener(infoButtonListener);
mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker marker) {
return null;
}
@Override
public View getInfoContents(Marker marker) {
// Setting up the infoWindow with current's marker info
infoTitle.setText(marker.getTitle());
infoSnippet.setText(marker.getSnippet());
//infoImage.setImage(marker.getMarker());
infoButtonListener.setMarker(marker);
// We must call this to set the current marker and infoWindow references
// to the MapWrapperLayout
mapWrapperLayout.setMarkerWithInfoWindow(marker, infoWindow);
return infoWindow;
}
});
// Let's add a couple of markers
mMap.addMarker(new MarkerOptions()
.title("Kecamatan Adipala")
.snippet("Kecamatan Adipala")
.position(ADIPALA)
.icon(bitmapDescriptorFromVector(getApplicationContext(), R.drawable.iconbuilding))
);
mMap.addMarker(new MarkerOptions()
.title("Kecamatan Bantarsari")
.snippet("Kecamatan Bantarsari")
.position(BANTARSARI).icon(bitmapDescriptorFromVector(getApplicationContext(), R.drawable.iconbuilding))
);
mMap.addMarker(new MarkerOptions()
.title("Kecamatan Binangun")
.snippet("Kecamatan Binangun")
.position(BINANGUN)
.icon(bitmapDescriptorFromVector(getApplicationContext(), R.drawable.iconbuilding))
);
mMap.addMarker(new MarkerOptions()
.title("Kecamatan Cilacap Utara")
.snippet("Kecamatan Cilacap Utara")
.position(CILACAPUTARA).icon(bitmapDescriptorFromVector(getApplicationContext(), R.drawable.iconbuilding))
);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapWrapperLayout = (MapWrapperLayout)findViewById(R.id.map_relative_layout);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
Anyone can help me? Thanks