Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.example.pppp.onex.InfoWindowData.getTitle()' on a null object reference
- at com.example.pppp.onex.CustomInfoWindowAdapter.getInfoContents(CustomInfoWindowAdapter.java:49)
- mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
- @Override
- public boolean onMarkerClick(final Marker marker) {
- db.collection("marcadores")
- .get()
- .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
- @Override
- public void onComplete(@NonNull Task<QuerySnapshot> task) {
- if (task.isSuccessful()) {
- for (final QueryDocumentSnapshot document : task.getResult()) {
- Log.d(TAG,String.valueOf(marker.getPosition().latitude));
- if(String.valueOf(marker.getPosition().latitude).equals(String.valueOf(document.getData().get("latitude"))) && String.valueOf(marker.getPosition().longitude).equals(String.valueOf(document.getData().get("longitude")))){
- InfoWindowData info = new InfoWindowData();
- info.setTitle(marker.getId());
- CustomInfoWindowAdapter customInfoWindow = new CustomInfoWindowAdapter(MapsActivity.this);
- mMap.setInfoWindowAdapter(customInfoWindow);
- marker.setTag(info);
- marker.showInfoWindow();
- break;
- }
- }
- } else {
- Log.w(TAG, "Error getting documents.", task.getException());
- }
- }
- });
- return false;
- }
- });
- public CustomInfoWindowAdapter(Context context){
- this.context = context;
- }
- @Override
- public View getInfoContents(final Marker m) {
- //Carga layout personalizado.
- //View v = inflater.inflate(R.layout.infowindow_layout, null);
- View v = ((Activity)context).getLayoutInflater()
- .inflate(R.layout.infowindow_layout, null);
- InfoWindowData infoWindowData = (InfoWindowData) m.getTag();
- TextView title = ((TextView)v.findViewById(R.id.infoWindowAdapterTextView));
- title.setText(infoWindowData.getTitle());
- return v;
- }
- public class InfoWindowData {
- private String title;
- public String getTitle() {
- return title;
- }
- public void setTitle(String title) {
- this.title = title;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement