diff --git a/res/layout/map_popup.xml b/res/layout/map_popup.xml --- a/res/layout/map_popup.xml +++ b/res/layout/map_popup.xml @@ -2,27 +2,34 @@ + android:background="@color/cardview_light_background" + android:padding="8dp"> + android:id="@+id/bubble_title" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textColor="@color/blue_500"/> + android:id="@+id/bubble_description" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center" + /> + android:layout_height="wrap_content" + android:visibility="gone" + /> + android:layout_width="wrap_content" + android:visibility="gone" + /> \ No newline at end of file diff --git a/src/it/reyboz/bustorino/ActivityMap.java b/src/it/reyboz/bustorino/ActivityMap.java --- a/src/it/reyboz/bustorino/ActivityMap.java +++ b/src/it/reyboz/bustorino/ActivityMap.java @@ -158,6 +158,8 @@ marker.setIcon(getResources().getDrawable(R.drawable.bus_marker)); // add to it a title marker.setTitle(stopName); + // set the description as the ID + marker.setSnippet(ID); // show popup info window of the searched marker if (isStartMarker) { diff --git a/src/it/reyboz/bustorino/map/CustomInfoWindow.java b/src/it/reyboz/bustorino/map/CustomInfoWindow.java --- a/src/it/reyboz/bustorino/map/CustomInfoWindow.java +++ b/src/it/reyboz/bustorino/map/CustomInfoWindow.java @@ -1,11 +1,15 @@ package it.reyboz.bustorino.map; import android.annotation.SuppressLint; +import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.util.Log; import android.view.MotionEvent; import android.view.View; +import android.widget.TextView; +import org.osmdroid.api.IMapView; import org.osmdroid.views.MapView; import org.osmdroid.views.overlay.infowindow.BasicInfoWindow; @@ -14,6 +18,20 @@ public class CustomInfoWindow extends BasicInfoWindow { + @Override + public void onOpen(Object item) { + super.onOpen(item); + + TextView descr_textView = (TextView) mView.findViewById(R.id.bubble_description); + CharSequence text = descr_textView.getText(); + if (text==null || !text.toString().isEmpty()){ + descr_textView.setVisibility(View.VISIBLE); + } else + descr_textView.setVisibility(View.GONE); + + mView.setElevation(3.2f); + } + @SuppressLint("ClickableViewAccessibility") public CustomInfoWindow(MapView mapView, String ID, String stopName) { // get the personalized layout