#android #android-studio #google-maps #infowindow
#Android #android-studio #google-карты #infowindow
Вопрос:
Я хочу запустить информационное окно с помощью кнопки, оно выполняется красиво. Я использую это, где я нашел на github.
Но, если я попытаюсь наложить на него слой GeoJSON, кнопка исчезнет
Я пробую много способов устранить эту ошибку, но я все еще сталкиваюсь с проблемой.
Эта ошибка, которую я обнаружил, кнопка исчезает
Это то, что я хочу, со слоем GeoJSON на нем
Вот моя основная деятельность
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);
}
Кто-нибудь может мне помочь?
Спасибо