Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] #4959 - Dynamic Sizing Of Default InfoWindow Based On Avail…
Browse files Browse the repository at this point in the history
…ability Of Title And Snippet Data
  • Loading branch information
bleege committed Jun 13, 2016
1 parent b3467a5 commit 4f622a7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;
Expand Down Expand Up @@ -222,9 +223,22 @@ void adaptDefaultMarker(Marker overlayItem, MapboxMap mapboxMap, MapView mapView
}
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
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;
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 {
Expand Down Expand Up @@ -61,6 +59,12 @@ private void addMarkers() {
.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.")
Expand Down

0 comments on commit 4f622a7

Please sign in to comment.