创建 – 矩形、点
Envelope envelope =
new Envelope(-123.0, 33.5, -101.0, 48.0, SpatialReferences.getWgs84());
Point pt =
new Point(34.056295, -117.195800, SpatialReferences.getWgs84());
PointCollection stateCapitalsPST =
new PointCollection(SpatialReferences.getWgs84());
stateCapitalsPST.add(-121.491014, 38.579065); // Sacramento, CA
stateCapitalsPST.add(-122.891366, 47.039231); // Olympia, WA
stateCapitalsPST.add(-123.043814, 44.93326); // Salem, OR
stateCapitalsPST.add(-119.766999, 39.164885); // Carson City, NV
Multipoint multipoint = new Multipoint(stateCapitalsPST);
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
创建 – 线、面
PointCollection borderCAtoNV =
new PointCollection(SpatialReferences.getWgs84());
borderCAtoNV.add(-119.992, 41.989);
borderCAtoNV.add(-119.994, 38.994);
borderCAtoNV.add(-114.620, 35.0);
Polyline polyline = new Polyline(borderCAtoNV);
PointCollection coloradoCorners =
new PointCollection(SpatialReferences.getWgs84());
coloradoCorners.add(-109.048, 40.998);
coloradoCorners.add(-102.047, 40.998);
coloradoCorners.add(-102.037, 36.989);
coloradoCorners.add(-109.048, 36.998);
Polygon polygon = new Polygon(coloradoCorners);
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
空间要素绘制 – SketchEditor
绘制类型(SketchCreationMode)
- POINT
- MULTIPOINT
- POLYLINE
- POLYGON
- FREEHAND_LINE
- FREEHAND_POLYGON
初始化地图
mainMapView = (MapView) findViewById(R.id.mainMapView);
mainBasemap = new Basemap(
TianDiTuMethodsClass.CreateTianDiTuTiledLayer(
TianDiTuMethodsClass.LayerType.TIANDITU_VECTOR_2000));
mainBasemap.getBaseLayers().add(
TianDiTuMethodsClass.CreateTianDiTuTiledLayer(
TianDiTuMethodsClass.LayerType.TIANDITU_VECTOR_ANNOTATION_CHINESE_2000));
mainArcGISMap = new ArcGISMap(mainBasemap);
mainMapView.setMap(mainArcGISMap);
mainSketchEditor = new SketchEditor();
mainSketchStyle = new SketchStyle();
mainSketchEditor.setSketchStyle(mainSketchStyle);
mainMapView.setSketchEditor(mainSketchEditor);
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
启动绘制
mPointButton = (ImageButton) findViewById(R.id.pointSketchButton);
mPointButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
//mainSketchEditor.stop();
mainSketchEditor.start(SketchCreationMode.POINT);
}
catch (Exception e)
{
e.getCause();
}
}
});
mPolylineButton = (ImageButton) findViewById(R.id.polylineSketchButton);
mPolylineButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
//mainSketchEditor.stop();
mainSketchEditor.start(SketchCreationMode.POLYLINE);
}
catch (Exception e)
{
e.getCause();
}
}
});
mPolygonButton = (ImageButton) findViewById(R.id.polygonSketchButton);
mPolygonButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
//mainSketchEditor.stop();
mainSketchEditor.start(SketchCreationMode.POLYGON);
}
catch (Exception e)
{
e.getCause();
}
}
});
mPolylineFreeheadButton = (ImageButton) findViewById(R.id.polylineFreeheadSketchButton);
mPolylineFreeheadButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
//mainSketchEditor.stop();
mainSketchEditor.start(SketchCreationMode.FREEHAND_LINE);
}
catch (Exception e)
{
e.getCause();
}
}
});
mPolygonFreeheadButton = (ImageButton) findViewById(R.id.polygonFreeheadSketchButton);
mPolygonFreeheadButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
//mainSketchEditor.stop();
mainSketchEditor.start(SketchCreationMode.FREEHAND_POLYGON);
}
catch (Exception e)
{
e.getCause();
}
}
});