display info when on move
This commit is contained in:
parent
b91931e833
commit
5349558ace
@ -32,13 +32,13 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
|
||||||
import com.google.android.gms.maps.GoogleMap;
|
import com.google.android.gms.maps.GoogleMap;
|
||||||
import com.google.android.gms.maps.OnMapReadyCallback;
|
import com.google.android.gms.maps.OnMapReadyCallback;
|
||||||
import com.google.android.gms.maps.SupportMapFragment;
|
import com.google.android.gms.maps.SupportMapFragment;
|
||||||
import com.google.android.gms.maps.model.BitmapDescriptor;
|
import com.google.android.gms.maps.model.BitmapDescriptor;
|
||||||
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
||||||
import com.google.android.gms.maps.model.LatLng;
|
import com.google.android.gms.maps.model.LatLng;
|
||||||
|
import com.google.android.gms.maps.model.Marker;
|
||||||
import com.google.android.gms.maps.model.MarkerOptions;
|
import com.google.android.gms.maps.model.MarkerOptions;
|
||||||
import com.safemobile.activities.AbstractLiveActivity;
|
import com.safemobile.activities.AbstractLiveActivity;
|
||||||
import com.safemobile.activities.AbstractSDParentActivity;
|
import com.safemobile.activities.AbstractSDParentActivity;
|
||||||
@ -102,6 +102,7 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
//value poll
|
//value poll
|
||||||
private double latPoll = 0;
|
private double latPoll = 0;
|
||||||
private double lngPoll = 0;
|
private double lngPoll = 0;
|
||||||
|
private ArrayList<Marker> markers = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -308,10 +309,6 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
this.googleMap = googleMap;
|
this.googleMap = googleMap;
|
||||||
GoogleMapsInfoBubble infoBubble = new GoogleMapsInfoBubble(getLayoutInflater(), this, getParentTab().SuperVehHash);
|
GoogleMapsInfoBubble infoBubble = new GoogleMapsInfoBubble(getLayoutInflater(), this, getParentTab().SuperVehHash);
|
||||||
this.googleMap.setInfoWindowAdapter(infoBubble);
|
this.googleMap.setInfoWindowAdapter(infoBubble);
|
||||||
// Add a marker in Sydney and move the camera
|
|
||||||
LatLng sydney = new LatLng(-34, 151);
|
|
||||||
this.googleMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
|
|
||||||
this.googleMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -445,6 +442,12 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
|
|
||||||
public void displayVehicle(boolean withZoom, double latZoom, double lngZoom) {
|
public void displayVehicle(boolean withZoom, double latZoom, double lngZoom) {
|
||||||
if (googleMap != null) {
|
if (googleMap != null) {
|
||||||
|
String openWindow = "";
|
||||||
|
for (Marker marker : markers) {
|
||||||
|
if (marker.isInfoWindowShown()) {
|
||||||
|
openWindow = marker.getTitle();
|
||||||
|
}
|
||||||
|
}
|
||||||
googleMap.clear();
|
googleMap.clear();
|
||||||
|
|
||||||
for (int i = 0; i < displayedVehicles.size(); i++) {
|
for (int i = 0; i < displayedVehicles.size(); i++) {
|
||||||
@ -458,7 +461,11 @@ public class LiveActivity extends AbstractLiveActivity implements OnMapReadyCall
|
|||||||
BitmapDescriptor markerIcon = getProperBitmap(tmpSuper.getLargeIcon(), tmpSuper.name);
|
BitmapDescriptor markerIcon = getProperBitmap(tmpSuper.getLargeIcon(), tmpSuper.name);
|
||||||
markerOptions.icon(markerIcon);
|
markerOptions.icon(markerIcon);
|
||||||
|
|
||||||
this.googleMap.addMarker(markerOptions);
|
Marker marker = this.googleMap.addMarker(markerOptions);
|
||||||
|
if (openWindow.equals(marker.getTitle()))
|
||||||
|
marker.showInfoWindow();
|
||||||
|
|
||||||
|
markers.add(marker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user