static public GraphicsLayer SHPtoPOINT(String shpfile) {
SpatialReference lSR = SpatialReference.create(26192);
Envelope lEnvolope = getSHPEnvelope(shpfile);//to create an extent for your graphics layer
GraphicsLayer graphicLayer = new GraphicsLayer(lSR, lEnvolope);
try {
File file = new File(shpfile);
ShapeFile shp = new ShapeFile(file);
ESRIPointRecord e = (ESRIPointRecord) shp.getNextRecord();
SimpleMarkerSymbol c_point = new SimpleMarkerSymbol(Color.BLACK, 1,
STYLE.CIRCLE);
while (e != null) {
graphicLayer.addGraphic(new Graphic(new Point(e.getX(), e
.getY()), c_point));
e = (ESRIPointRecord) shp.getNextRecord();
}
shp.close();
} catch (IOException e1) {
e1.printStackTrace();
}
return graphicLayer;
}
where to store the shapefiles in sd card (location path)?
File dbf = new File(Environment.getExternalStorageDirectory() + "/islreali/TabaYeud.dbf"); File shape = new File(Environment.getExternalStorageDirectory() + "/islreali/TabaYeud.shp"); File shx = new File(Environment.getExternalStorageDirectory() + "/islreali/TabaYeud.shx"); try { URL dbfUrl = dbf.toURI().toURL(); EsriPlugIn epi = new EsriPlugIn("name", dbfUrl, shape.toURI().toURL(), shx.toURI().toURL()); EsriGraphicList eGList = epi.getEsriGraphicList(); Map<Object, Object> attr = eGList.getAttributes(); } catch (Exception e) { e.printStackTrace(); }
static public GraphicsLayer SHPtoPOINT(String shpfile) {
SpatialReference lSR = SpatialReference.create(26192);
Envelope lEnvolope = getSHPEnvelope(shpfile);//to create an extent for your graphics layer
GraphicsLayer graphicLayer = new GraphicsLayer(lSR, lEnvolope);
try {
File file = new File(shpfile);
ShapeFile shp = new ShapeFile(file);
ESRIPointRecord e = (ESRIPointRecord) shp.getNextRecord();
SimpleMarkerSymbol c_point = new SimpleMarkerSymbol(Color.BLACK, 1,
STYLE.CIRCLE);
while (e != null) {
graphicLayer.addGraphic(new Graphic(new Point(e.getX(), e
.getY()), c_point));
e = (ESRIPointRecord) shp.getNextRecord();
}
shp.close();
} catch (IOException e1) {
e1.printStackTrace();
}
return graphicLayer;
}
"From where will I get SimpleMarkerSymbol class. I downloaded openmap 5.0 and the jars from there but could not find SimpleMarkerSymbol , Envelope , SpatialReference classes?"
Download code from:
http://www.openmap.org/
and then point to the jar files in the "lib" directory through the Java Build Path Libraries Tab in Eclsipse
Can you tell me how to use the openmap after add the lib?
or show me a sample/tutorial of open shape file from SD card by openmap.