Code example for GoogleMap

Methods: addMarker, addPolygon

0
 
		// Remove previously drawn rect 
		if (rect != null) rect.remove();
		 
		// Add rectangle to the map 
		rect = map.addPolygon(new PolygonOptions()
		    .add(c1,c2,c3,c4) // 4 corners, ccw
		    .strokeWidth(5)
		    .strokeColor(Color.GREEN)
		    .fillColor(0x6600ff00));
		 
		// Set coordinates that will be passed back to the group creation activity 
		gps1.setLatitude(c1.latitude); gps1.setLongitude(c1.longitude);
		gps2.setLatitude(c3.latitude); gps2.setLongitude(c3.longitude);
 
		// Top left marker 
		if (m1 != null) m1.remove();
		m1 = map.addMarker(new MarkerOptions()
			    	.position(c1)
			    	.draggable(true)
			    	.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
		 
		// Top right marker 
		if (m2 != null) m2.remove();
		m2 = map.addMarker(new MarkerOptions()
			    	.position(c2)
			    	.draggable(true).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));		
		 
		// Bottom right marker 
		if (m3 != null) m3.remove();
		m3 = map.addMarker(new MarkerOptions()
		    	.position(c3)
		    	.draggable(true).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE)));
 
		// Bottom right marker 
		if (m4 != null) m4.remove();
		m4 = map.addMarker(new MarkerOptions()
		    	.position(c4)
		    	.draggable(true).icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW)));
	} 
	 
	private class GeocoderTask extends AsyncTask<String, Void, List<Address>>{