餘米開發一個應用程序中,用戶繪製多邊形。我有一套LatLng。現在我想顯示屬於LatLng集合的所有標記。所有不屬於我的標記我想刪除它。我附上了一張圖片。我怎麼能做到這一點。提前致謝。如何獲取區域從一組經緯度的谷歌地圖
static final LatLng HAMBURG = new LatLng(53.558, 9.927);
static final LatLng cz1 = new LatLng(53.600, 9.927);
static final LatLng KIEL = new LatLng(53.551, 9.993);
private GoogleMap map;
private CameraPosition cameraPosition;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
.title("Hamburg"));
Marker cz = map.addMarker(new MarkerOptions().position(cz1)
.title("cz"));
Marker kiel = map.addMarker(new MarkerOptions()
.position(KIEL)
.title("Kiel")
.snippet("Kiel is cool")
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.ic_launcher)));
// Move the camera instantly to hamburg with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));
Button button = (Button) findViewById(R.id.map_button);
button.setOnClickListener(this);
// Zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
map.setOnCameraChangeListener(this);
}
@Override
public void onCameraChange(CameraPosition arg0) {
cameraPosition = arg0;
}
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, FreeDrawActivity.class);
Bundle bundle = new Bundle();
bundle.putParcelable("position", cameraPosition);
intent.putExtras(bundle);
startActivityForResult(intent, 0);
}
@Override
protected void onActivityResult(int arg0, int arg1, Intent arg2) {
super.onActivityResult(arg0, arg1, arg2);
if (arg2 != null) {
Draw_Map((ArrayList<LatLng>) arg2.getSerializableExtra("result"));
}
}
public void Draw_Map(ArrayList<LatLng> val) {
PolygonOptions rectOptions = new PolygonOptions();
rectOptions.addAll(val);
rectOptions.strokeColor(Color.BLUE);
rectOptions.strokeWidth(7);
rectOptions.fillColor(Color.argb(125, 255, 255, 255));
Polygon polygon = map.addPolygon(rectOptions);
}
我想要顯示的多邊形繪圖內部的所有點。 – 2014-12-05 11:47:44
該算法將允許您過濾多邊形內的哪些點。然後畫這些。 – Moses 2014-12-05 12:13:42