0
我用Draggable Circle庫來繪製地圖上的圓。它在我的地圖上工作正常,但我想在地圖上繪製用戶選擇的形狀,如圓形,矩形或多邊形。如果用戶在地圖上選擇了圓形圖像,則需要繪製圓形或其他圓形。我如何在Map上實現這一點,並且在Map上只應繪製一個圖像,而不是多個Circle或其他圖像。請幫幫我。如何在Google地圖上製作一個拖曳山牆圈?
我的代碼是在這裏
@Override
protected void onStart() {
super.onStart();
acti_drawingzone_clearTxt.setOnClickListener(this);
acti_drawingzone_circleImg.setOnClickListener(this);
}
private AdapterView.OnItemClickListener mAutocompleteClickListener = new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
final PlaceArrayAdapter.PlaceAutocomplete item = mPlaceArrayAdapter
.getItem(position);
final String placeId = String.valueOf(item.placeId);
Log.i(LOG_TAG, "Selected: " + item.description);
PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
.getPlaceById(mGoogleApiClient, placeId);
placeResult.setResultCallback(mUpdatePlaceDetailsCallback);
Log.i(LOG_TAG, "Fetching details for ID: " + item.placeId);
}
};
private ResultCallback<PlaceBuffer> mUpdatePlaceDetailsCallback = new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(PlaceBuffer places) {
if (!places.getStatus().isSuccess()) {
Log.e(LOG_TAG, "Place query did not complete. Error: "
+ places.getStatus().toString());
return;
}
// Selecting the first object buffer.
final Place place = places.get(0);
CharSequence attributions = places.getAttributions();
queried_location = place.getLatLng();
lattitude = queried_location.latitude;
lngnitude = queried_location.longitude;
CameraPosition SYDNEY = new CameraPosition.Builder()
.target(new LatLng(lattitude, lngnitude)).zoom(11)
.bearing(90).tilt(30).build();
googleMap.animateCamera(CameraUpdateFactory
.newCameraPosition(SYDNEY));
googleMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.ic_map_color))
.anchor(0.0f, 1.0f) // Anchors the marker on the bottom left
.position(new LatLng(lattitude, lngnitude)));
}
};
@Override
public void onClick(View arg0) {
switch (arg0.getId()) {
case R.id.acti_drawingzone_clearTxt:
acti_drawingzone_autoTxt.setText("");
break;
case R.id.acti_drawingzone_circleImg:
setupMap();
break;
default:
break;
}
}
@Override
public void onLocationChanged(Location arg0) {
// TODO Auto-generated method stub
}
@Override
public void onConnected(Bundle arg0) {
mPlaceArrayAdapter.setGoogleApiClient(mGoogleApiClient);
Log.i(LOG_TAG, "Google Places API connected.");
}
@Override
public void onConnectionSuspended(int arg0) {
mPlaceArrayAdapter.setGoogleApiClient(null);
Log.e(LOG_TAG, "Google Places API connection suspended.");
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Log.e(LOG_TAG, "Google Places API connection failed with error code: "
+ connectionResult.getErrorCode());
Toast.makeText(
this,
"Google Places API connection failed with error code:"
+ connectionResult.getErrorCode(), Toast.LENGTH_LONG)
.show();
}
@Override
protected void onResume() {
super.onResume();
setupMap();
}
private void setupMap() {
circleManager = new MapAreaManager(googleMap,
4, Color.RED, Color.HSVToColor(70, new float[] {1, 1, 200}), //styling
R.drawable.move, R.drawable.resize,0.5f, 0.5f, 0.5f, 0.5f,
new MapAreaMeasure(100, MapAreaMeasure.Unit.pixels), //circles will start with 100 pixels (independent of zoom level)
new CircleManagerListener() { //listener for all circle events
@Override
public void onResizeCircleEnd(MapAreaWrapper draggableCircle) {
Toast.makeText(ActivityDrawingZone.this, "do something on drag end circle: " + draggableCircle, Toast.LENGTH_SHORT).show();
}
@Override
public void onCreateCircle(MapAreaWrapper draggableCircle) {
Toast.makeText(ActivityDrawingZone.this, "do something on crate circle: " + draggableCircle, Toast.LENGTH_SHORT).show();
}
@Override
public void onMoveCircleEnd(MapAreaWrapper draggableCircle) {
Toast.makeText(ActivityDrawingZone.this, "do something on moved circle: " + draggableCircle, Toast.LENGTH_SHORT).show();
}
@Override
public void onMoveCircleStart(MapAreaWrapper draggableCircle) {
Toast.makeText(ActivityDrawingZone.this, "do something on move circle start: " + draggableCircle, Toast.LENGTH_SHORT).show();
}
@Override
public void onResizeCircleStart(MapAreaWrapper draggableCircle) {
Toast.makeText(ActivityDrawingZone.this, "do something on resize circle start: " + draggableCircle, Toast.LENGTH_SHORT).show();
}
@Override
public void onMinRadius(MapAreaWrapper draggableCircle) {
Toast.makeText(ActivityDrawingZone.this, "do something on min radius: " + draggableCircle, Toast.LENGTH_SHORT).show();
}
@Override
public void onMaxRadius(MapAreaWrapper draggableCircle) {
Toast.makeText(ActivityDrawingZone.this, "do something on max radius: " + draggableCircle, Toast.LENGTH_LONG).show();
}
});
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lattitude, lngnitude), 6));
}
}
HI @AniV .. thnxx for response ..你有任何鏈接或示例代碼,這使得它非常靈活....請幫助我的兄弟。我非常需要這個Badly – kitkat