2
私は現在、開いている地図上のユーザーの位置マーカーでGoogleマップを持っています。ユーザーが地図上の位置をクリックすると、青いマーカーが表示されます(行き先マーカー)この画像のようなマーカーと目的地のマーカー:アンドロイドの道路にポリラインを描く
@Override
public void onMapReady(final GoogleMap googleMap) {
this.googleMap = googleMap;
googleMap.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() {
@Override
public void onMapLongClick(LatLng latLng) {
destinationLocation = new Location(LocationManager.GPS_PROVIDER);
destinationLocation.setLatitude(latLng.latitude);
destinationLocation.setLongitude(latLng.longitude);
destinationMarker = googleMap.addMarker(new MarkerOptions().position(latLng).title("your destination").icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_destination_marker)));
Polyline line = googleMap.addPolyline(new PolylineOptions()
.add(new LatLng(userLocation.getLatitude(),
userLocation.getLongitude()), new LatLng(destinationLocation.getLatitude(),
destinationLocation.getLongitude())).color(Color.BLUE).width(10));
}
});
}