[android] #4959 - Dynamic Sizing Of Default InfoWindow Based On Availability Of Title And Snippet Data
This commit is contained in:
@@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.annotations;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.PointF;
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -222,9 +223,22 @@ public class InfoWindow {
|
||||
}
|
||||
mMapboxMap = new WeakReference<>(mapboxMap);
|
||||
String title = overlayItem.getTitle();
|
||||
((TextView) view.findViewById(R.id.infowindow_title)).setText(title);
|
||||
TextView titleTextView = ((TextView) view.findViewById(R.id.infowindow_title));
|
||||
if (!TextUtils.isEmpty(title)) {
|
||||
titleTextView.setText(title);
|
||||
titleTextView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
titleTextView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
String snippet = overlayItem.getSnippet();
|
||||
((TextView) view.findViewById(R.id.infowindow_description)).setText(snippet);
|
||||
TextView snippetTextView = ((TextView) view.findViewById(R.id.infowindow_description));
|
||||
if (!TextUtils.isEmpty(snippet)) {
|
||||
snippetTextView.setText(snippet);
|
||||
snippetTextView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
snippetTextView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
InfoWindow setBoundMarker(Marker boundMarker) {
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
@@ -16,7 +15,6 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class InfoWindowActivity extends AppCompatActivity implements OnMapReadyCallback, MapboxMap.OnInfoWindowCloseListener, MapboxMap.OnMapLongClickListener, MapboxMap.OnInfoWindowClickListener, MapboxMap.OnInfoWindowLongClickListener {
|
||||
@@ -61,6 +59,12 @@ public class InfoWindowActivity extends AppCompatActivity implements OnMapReadyC
|
||||
.snippet("E St NW with 17th St NW")
|
||||
.position(new LatLng(38.8954236, -77.0394623)));
|
||||
|
||||
mapboxMap.addMarker(new MarkerOptions().title("The Ellipse").position(new LatLng(38.89393, -77.03654)));
|
||||
|
||||
mapboxMap.addMarker(new MarkerOptions().position(new LatLng(38.89596, -77.03434)));
|
||||
|
||||
mapboxMap.addMarker(new MarkerOptions().snippet("Lafayette Square").position(new LatLng(38.89949, -77.03656)));
|
||||
|
||||
Marker marker = mapboxMap.addMarker(new MarkerOptions()
|
||||
.title("White House")
|
||||
.snippet("The official residence and principal workplace of the President of the United States, located at 1600 Pennsylvania Avenue NW in Washington, D.C. It has been the residence of every U.S. president since John Adams in 1800.")
|
||||
|
||||
Reference in New Issue
Block a user