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