In this post, we saw how to implement Geolocation Maps in Oracle Apex. In many use cases, you may need to draw certain features using coordinate and geometry information. Spatial Geometry objects can be used in such cases to make the geoprocessing easier.
Spatial geometry objects are drawn on the background map based on data in a table or returned by our query. Apex Maps support a rich set of built-in marker icons and shapes. Below are the supported spatial geometry objects in Apex Maps Region:
Points - Points display as markers e.g. user's current location or any specific point on the map.
Lines - Lines represent features like roads or it can be line drawn between variety of points.
Polygons - Polygons represent areas like states or countries or it can be drawn to show any other areas on the map.
Heat Map - Heat Maps are used to visualize the point density.
Extruded Polygons - These are displayed as three-dimensional, extruded Polygons. The height of the 3D object is based on a Numeric column value returned by our query.
Spatial geometry objects can be based on below sources:
Geometry Column - Supported datatypes include SDO_GEOMETRY, VARCHAR2, or CLOB. VARCHAR2 and CLOB columns must contain geometry information in GeoJSON format.
Numeric Columns - Columns representing longitude and latitude values but this option applies only to Point and Heat Map objects.
Let's take a took at each of these Spatial Geometry Objects and how we can use them in Apex Maps Region.
1. Points:
- Let's create a Layer in our Map
Layer Type: Points
As we learned above, Points layer can be based on Numeric values one for Latitude and other for Longitude. So let's use a simple query with sample values indicating a specific point on the map.
SQL Query:
SELECT TO_NUMBER('40.79261211884605') P_LAT
,TO_NUMBER('-73.95252971760179') P_LONG
FROM DUAL
- Let's specify fa-location-arrow in Icon CSS Classes under Point Objects section.
- Run the App.
- As we can see the Point is denoted by an Arrow at the exact point based on Latitude and Longitude.
2. Lines:
- Let's create a new Layer in our Map
Layer Type: Lines
Lines layer needs GeoJSON format as the source. So let's build a query to generate data in GeoJSON format.
This will consist of any two points on the map (from and to) and their corresponding Latitude and Longitude values.
SQL Query:
SELECT
'
{
"type": "LineString",
"coordinates": [
[
-73.95252971760179,
40.79261211884605
],
[
-73.95345327758079,
40.791114880267148
]
]
}
' geojson_val
FROM DUAL
- Let's specify the line properties:
Stroke Style: Dotted
Stroke Color: Red
Stroke Width: 7
3. Polygons:
- Let's create a new Layer in our Map
Layer Type: Polygons
Polygons layer needs GeoJSON format as the source. So let's build a query to generate data in GeoJSON format.
This will consist of a number of points on the map (forming a Polygonal shape) and their corresponding Latitude and Longitude values. I'm forming the Polygon using 5 points on the map.
SQL Query:
SELECT
'
{
"type": "Polygon",
"coordinates": [
[
[
-73.9684379656287,
40.78569943754278
],
[
-73.9629016692047,
40.78849384000406
],
[
-73.95766551865343,
40.789760807246765
],
[
-73.95895386999608,
40.783522052350584
]
,
[
-73.96569143411632,
40.7829049598581
]
,
[
-73.9684379656287,
40.78569943754278
]
]
]
}
' geojson_val
FROM DUAL
- Let's specify the Appearance properties:
Fill Color: Grey
Fill Opacity: 0.5
Stroke Color: Red
- Run the App.
- As we can see a Semi-Transparent Polygon drawn over our map in Red color based on our coordinates.
We can also see a new check-box has been added on the map indicating controls for Polygon layer.
4. Extruded Polygons:
- Let's create a new Layer in our Map
Layer Type: Extruded Polygons
Polygons layer needs GeoJSON format as the source. So let's build a query to generate data in GeoJSON format.
This will consist of a number of points on the map (forming a Polygonal shape) and their corresponding Latitude and Longitude values. I'm forming the Polygon using 4 points on the map to show a building in 3D format.
Here' we can see the query also has another column E_VAL with value 70 . This indicates the Extrusion Value for this layer which is basically the value to determine the height of the extruded polygon.
SQL Query:
SELECT
'
{
"type": "Polygon",
"coordinates": [
[
[
-73.95243322590251,
40.79222980941566
],
[
-73.95211869237345,
40.79209869069768
],
[
-73.95250182333042,
40.79162315684402
],
[
-73.95284231859179,
40.791672689498604
]
,
[
-73.95243322590251,
40.79222980941566
]
]
]
}
' geojson_val
,70 E_VAL
FROM DUAL
- Let's specify the Appearance properties:
Fill Color: Lavender
Extrusion Value Column: E_VAL (This is the column returned by our query)
Unit: Meter
Fill Opacity: 0.5
- Run the App.
- As we can see a Semi-Transparent Polygon drawn over a building in Lavender color based on our coordinates.
We can also see a new check-box has been added on the map indicating controls for Extruded Polygon layer.