Code example for CircleOptions

Methods: center, fillColor, radius, strokeColor

0
package com.android.lonoti.activies.map; 
 
import java.util.HashMap; 
import java.util.List; 
import java.util.Map; 
 
import com.android.lonoti.R; 
import com.android.lonoti.R.id; 
import com.android.lonoti.R.layout; 
import com.android.lonoti.R.menu; 
import com.android.lonoti.activities.LonotiEventCreate; 
import com.android.lonoti.adapter.PlacesAutoCompleteAdapter; 
import com.android.lonoti.adapter.PopupAdapter; 
import com.android.lonoti.adapter.data.MarkerContent; 
import com.android.lonoti.bom.payload.Location; 
import com.android.lonoti.exception.LocationException; 
import com.android.lonoti.exception.NetworkException; 
import com.android.lonoti.location.LonotiLocationManager; 
import com.android.lonoti.location.LonotiLocationPlaces; 
import com.android.lonoti.network.LonotiAsyncServiceRequest; 
import com.android.lonoti.network.ILonotiTaskListener; 
import com.google.android.gms.common.GooglePlayServicesUtil; 
import com.google.android.gms.maps.CameraUpdate; 
import com.google.android.gms.maps.CameraUpdateFactory; 
import com.google.android.gms.maps.GoogleMap; 
import com.google.android.gms.maps.SupportMapFragment; 
import com.google.android.gms.maps.GoogleMap.OnMapLongClickListener; 
import com.google.android.gms.maps.model.BitmapDescriptorFactory; 
import com.google.android.gms.maps.model.Circle; 
import com.google.android.gms.maps.model.CircleOptions; 
import com.google.android.gms.maps.model.LatLng; 
import com.google.android.gms.maps.model.Marker; 
import com.google.android.gms.maps.model.MarkerOptions; 
 
import android.app.AlertDialog; 
import android.content.Intent; 
import android.graphics.Color; 
import android.location.LocationListener; 
import android.os.AsyncTask; 
import android.os.Bundle; 
import android.os.Handler; 
import android.os.Looper; 
import android.support.v4.app.FragmentActivity; 
import android.text.Editable; 
import android.text.TextWatcher; 
import android.util.Log; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.view.View; 
import android.widget.AdapterView; 
import android.widget.AdapterView.OnItemClickListener; 
import android.widget.AutoCompleteTextView; 
import android.widget.LinearLayout; 
import android.widget.SearchView; 
import android.widget.SeekBar; 
import android.widget.SimpleAdapter; 
import android.widget.TextView; 
import android.widget.SeekBar.OnSeekBarChangeListener; 
 
public class MapSelectActivity extends FragmentActivity { 
 
	static final LatLng HAMBURG = new LatLng(53.558, 9.927);
	 
	private Marker marker;
	private Circle circle;
	private GoogleMap map;
	private TextView radiusText;
	Map<Marker, MarkerContent> data;
	Location selectedLocation;
	Location presentLocation;
	AutoCompleteTextView mapAutoSearchAutoCompleteTextView;
	PlacesAutoCompleteAdapter adapter;
	String reference;
	private String markerDescription;
	LinearLayout locationRadiusLatlongLayout;
	 
	@Override 
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_map_select); 
		 
		locationRadiusLatlongLayout = (LinearLayout) findViewById(R.id.location_radius_latlong_layout);
		 
		int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
		 
		SupportMapFragment fr = ((SupportMapFragment)  getSupportFragmentManager().findFragmentById(R.id.map));
		 
		initMapAutoSearchAutoCompleteTextView(); 
		 
		map = fr.getMap();
 
		map.setMyLocationEnabled(true);
		 
		getPresentLocation(); 
 
		String lat = "0";
		String lon = "0";
		 
		if(getIntent().hasExtra("lonoti_location_latitude") && getIntent().hasExtra("lonoti_location_description")){ 
			 
			lat = getIntent().getStringExtra("lonoti_location_latitude");
			lon = getIntent().getStringExtra("lonoti_location_description");
			 
		}else{ 
			 
			if(presentLocation != null){
			 
				lat = presentLocation.getLat();
				lon = presentLocation.getLon();
				 
			} 
			 
		} 
		 
		markerDescription = getIntent().getStringExtra("lonoti_location_description");
		 
		LatLng selectedLocation = new LatLng(Double.valueOf(lat),Double.valueOf(lon));
		 
	    Marker selectedMarker = map.addMarker(new MarkerOptions().position(selectedLocation));
	    map.moveCamera(CameraUpdateFactory.newLatLngZoom(selectedLocation, 15));
 
	    // Zoom in, animating the camera. 
	    map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
	     
	    data = new HashMap<Marker, MarkerContent>();
		 
		MarkerContent c2 = new MarkerContent("1");
		data.put(selectedMarker, c2);
		 
		map.setInfoWindowAdapter(new PopupAdapter(this, getLayoutInflater(), data));
		 
		map.setOnMapLongClickListener(new OnMapLongClickListener() {
			 
			@Override 
			public void onMapLongClick(LatLng arg0) {
				// TODO Auto-generated method stub 
				 
				if(marker != null){
					marker.remove();
				} 
				 
				marker = map.addMarker(new MarkerOptions().position(arg0));
				data.put(marker, new MarkerContent("3"));
				 
				Location location = new Location(String.valueOf(marker.getPosition().latitude), String.valueOf(marker.getPosition().longitude), "");
				 
				AsyncTask<Object, Integer, Long> execute = new LonotiAsyncServiceRequest(new ILonotiTaskListener() {
					 
					@Override 
					public void doTask(String response) {
						// TODO Auto-generated method stub 
						markerDescription = response;
					} 
 
					@Override 
					public void doTask(Location loc) {
						// TODO Auto-generated method stub 
					} 
				}); 
				 
				execute.execute("LOCATION_SEARCH",location);
				 
				/*try { 
					markerDescription = LonotiLocationPlaces.getLocationDescription(location); 
				} catch (NetworkException e) { 
					// TODO Auto-generated catch block 
					e.printStackTrace(); 
				}*/ 
				 
			} 
		}); 
 
		TextView locationText = (TextView) findViewById(R.id.location_text);
		 
		locationText.setText(lat + ", " + lon);
 
		radiusText = (TextView) findViewById(R.id.radius_text);
 
		SeekBar bar = (SeekBar) findViewById(R.id.seekBar1);
		 
		//bar.setMax(48); 
		bar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
			 
			@Override 
			public void onStopTrackingTouch(SeekBar arg0) {
				// TODO Auto-generated method stub 
				 
			} 
			 
			@Override 
			public void onStartTrackingTouch(SeekBar arg0) {
				// TODO Auto-generated method stub 
				 
			} 
			 
			@Override 
			public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
				// TODO Auto-generated method stub 
				radiusText.setText(String.valueOf((arg1 + 2)/2.0) + "Km");
				if(circle != null){
					circle.remove();
				} 
				CircleOptions co = new CircleOptions();
				co.center(marker.getPosition());
				co.radius((arg1+2)*500);
				co.fillColor(Color.TRANSPARENT);
				co.strokeColor(Color.BLUE);
				circle = map.addCircle(co);
				 
			} 
		});