diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-09-26 21:51:07 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-09-26 21:51:07 +0200 |
commit | 564acef3dc2f1fe74c164563889b20b9943322a5 (patch) | |
tree | f054fc33b89440097cbd8b29384852024e50d4a4 /src/main/java | |
parent | 53d4248e82e4d3209a04bd870b9f79bfa2c8bf31 (diff) |
make InfoWindow unhideable
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java b/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java index d9b71a8da..38dc8fead 100644 --- a/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ShowLocationActivity.java @@ -35,6 +35,7 @@ public class ShowLocationActivity extends Activity implements OnMapReadyCallback private LatLng mLocation; private String mLocationName; private MarkerOptions options; + private Marker marker; class InfoWindowAdapter implements GoogleMap.InfoWindowAdapter { @@ -150,19 +151,27 @@ public class ShowLocationActivity extends Activity implements OnMapReadyCallback return address; } - private void markAndCenterOnLocation(final LatLng location, String name) { - this.mGoogleMap.clear(); + private void markAndCenterOnLocation(final LatLng location, String name) { + mGoogleMap.clear(); options = new MarkerOptions(); options.position(location); double longitude = mLocation.longitude; double latitude = mLocation.latitude; - this.mGoogleMap.setInfoWindowAdapter(new InfoWindowAdapter()); - + mGoogleMap.setInfoWindowAdapter(new InfoWindowAdapter()); + if (name != null) { + options.title(name); + } if (latitude != 0 && longitude != 0) { new AsyncTask<Void, Void, Void>() { String address = null; @Override + protected void onPreExecute() { + super.onPreExecute(); + mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(location, Config.DEFAULT_ZOOM)); + } + + @Override protected Void doInBackground(Void... params) { address = getAddress(ShowLocationActivity.this, location); return null; @@ -172,14 +181,17 @@ public class ShowLocationActivity extends Activity implements OnMapReadyCallback protected void onPostExecute(Void result) { super.onPostExecute(result); options.snippet(String.valueOf(address)); - mGoogleMap.addMarker(options).showInfoWindow(); + marker = mGoogleMap.addMarker(options); + marker.showInfoWindow(); } }.execute(); } - if (name != null) { - options.title(name); - } - this.mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(location, Config.DEFAULT_ZOOM)); - } + mGoogleMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() { + @Override + public void onMapClick(LatLng latLng) { + marker.showInfoWindow(); + } + }); + } } |