I'm having trouble putting my current/updated location on the map which has other data. please see the image below. I need it because I will do a distance between the vehicle location and my current location, anyways how to do it? this activity is extended by fragment. I really need your help.
This is my OnMapReady
:
public void onMapReady(GoogleMap googleMap) {
mMapProximity = googleMap;
mMapProximity.setBuildingsEnabled(true);
mMapProximity.getUiSettings().setRotateGesturesEnabled(false);
setUpMap();
}
private void setUpMap() {
mMapProximity.clear();
mMapProximity.setMapType(GoogleMap.MAP_TYPE_NORMAL);
mMapProximity.setIndoorEnabled(true);
mMapProximity.setBuildingsEnabled(true);
mMapProximity.getUiSettings().setZoomControlsEnabled(false);
final Double lati = Double.parseDouble(latitudeProxListMap);
final Double longi = Double.parseDouble(longitudeProxListMap);
m = mMapProximity.addMarker(new MarkerOptions()
.position(new LatLng(lati, longi))
.anchor(0.5f, 0.5f)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_logo))
.visible(true));
mMapProximity.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
marker.showInfoWindow();
}
});
mMapProximity.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lati, longi), 17.0f));
mMapProximity.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(final Marker marker) {
if (marker.isInfoWindowShown()) {
marker.hideInfoWindow();
} else {
marker.showInfoWindow();
}
return true;
}
});
mMapProximity.setInfoWindowAdapter(new MarkerInfoWindowAdapter());
m.showInfoWindow();
}
class MarkerInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {
@Override
public View getInfoWindow(Marker marker) {
return null;
}
@Override
public View getInfoContents(Marker marker) {
View v = getActivity().getLayoutInflater().inflate(R.layout.info_vehicle_list_map, null);
TextView title =v.findViewById(R.id.title);
TextView snippet =v.findViewById(R.id.snippet);
snippet.setVisibility(View.GONE);
title.setText("Location: " + location);
return v;
}
}