0
Google지도에서 몇 가지 사항을 보여주고 있습니다. 첫 번째로드에서 표시 할 수 있습니다. onMapReady 함수를 사용합니다.안드로이드에서 새로운 좌표로지도 마커를 다시 그릴 수있는 방법
@Override
public void onMapReady(GoogleMap googleMap) {
map = googleMap;
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
map.setMyLocationEnabled(true);
LatLng driver_point = new LatLng(driver_latitude, driver_longitude);
LatLng pickup_point = new LatLng(pickup_latitude, pickup_longitude);
LatLng drop_point = new LatLng(drop_latitude, drop_longitude);
LatLngBounds.Builder builder = new LatLngBounds.Builder();
if (driver_point.latitude != 0.0)
builder.include(driver_point);
builder.include(pickup_point);
builder.include(drop_point);
LatLngBounds bounds = builder.build();
int width = getResources().getDisplayMetrics().widthPixels;
int height = getResources().getDisplayMetrics().heightPixels;
int padding = (int) (width * 0.10);
CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, width, height, padding);
map.animateCamera(cu);
if (driver_point.latitude != 0.0)
markerPoints.add(driver_point);
markerPoints.add(pickup_point);
markerPoints.add(drop_point);
// Creating MarkerOptions
MarkerOptions driver_opt = new MarkerOptions();
// Setting the position of the marker
driver_opt.position(driver_point);
driver_opt.icon(BitmapDescriptorFactory.fromResource(R.drawable.car_tiny));
map.addMarker(driver_opt);
// Creating MarkerOptions
MarkerOptions pickup_opt = new MarkerOptions();
// Setting the position of the marker
pickup_opt.position(pickup_point);
pickup_opt.icon(BitmapDescriptorFactory.fromResource(R.drawable.pickup_icon));
map.addMarker(pickup_opt);
MarkerOptions drop_opt = new MarkerOptions();
// Setting the position of the marker
drop_opt.position(drop_point);
drop_opt.icon(BitmapDescriptorFactory.fromResource(R.drawable.dropoff_icon));
map.addMarker(drop_opt);
}
서버 호출 후 마커를 새로운 것으로 업데이트하려고합니다. 어떻게하면 될까요? 미리 감사드립니다.
myMarker.setPosition (newLatLng); – james