Build an Application to Show a map from a database

3478
3
Jump to solution
06-15-2016 06:06 PM
CarlosErazo
New Contributor

How to Build a Desktop Java Application to Show a map from a database (Oracle, Postgres, SQL Server, etc).

0 Kudos
1 Solution

Accepted Solutions
VijayGandhi
New Contributor III

You would need to create a Feature Service using ArcMap (see What is a feature service?—Documentation | ArcGIS for Server ). It can then be added as a FeatureLayer to the Java application (Example: Feature layer feature service—ArcGIS Runtime SDK for Java (Quartz Beta) | ArcGIS for Developers ).

If you simply want to display the data from the database, you could read data from the database (using JDBC for example), and then add the data as Graphics to a GraphicsOverlay (Example: Add graphics overlays to your app—ArcGIS Runtime SDK for Java (Quartz Beta) | ArcGIS for Developers )

View solution in original post

3 Replies
VijayGandhi
New Contributor III

You would need to create a Feature Service using ArcMap (see What is a feature service?—Documentation | ArcGIS for Server ). It can then be added as a FeatureLayer to the Java application (Example: Feature layer feature service—ArcGIS Runtime SDK for Java (Quartz Beta) | ArcGIS for Developers ).

If you simply want to display the data from the database, you could read data from the database (using JDBC for example), and then add the data as Graphics to a GraphicsOverlay (Example: Add graphics overlays to your app—ArcGIS Runtime SDK for Java (Quartz Beta) | ArcGIS for Developers )

CarlosErazo
New Contributor

Thanks for the answer, Vijay. Exactly, I just want to display the data from the database, like Oracle, SQL Server or Postgres. So, how could I read data from the database?

0 Kudos
VijayGandhi
New Contributor III

First step would be read the data from the database. Here is an example using JDBC - Lesson: JDBC Introduction (The Java™ Tutorials > JDBC(TM) Database Access).

Next step is to create a Graphic using the Runtime API. Examples at Add graphics and text to graphics overlays—ArcGIS Runtime SDK for Java (Quartz Beta) | ArcGIS for De...

For example if you have read fields called lat and lng in your database table, then you could create a Graphic like this:

SpatialReference wgs84 = SpatialReferences.getWgs84();

Point location = new Point(lng, lat, wgs84);

SimpleMarkerSymbol marker = new SimpleMarkerSymbol(new RgbColor(255, 0, 0, 255), 10, SimpleMarkerSymbol.Style.CIRCLE);

Graphic graphic = new Graphic(location, marker);

graphicOverlay.getGraphics().add(graphic);