In this samples we are exploring the usage of the M.App Enterprise Query API to deal with database content in a Browser App.
The App is comprised of 2 Panels:
Here is a video showing the App in action:
The App can be simply configured using the 2 panels and customizing them with the source code attached to this article (QueryAPI.zip).
The main idea is to build a SQL query that will perform a spatial relation from the Airports table and the current map extent. We are using a PostGIS database in this implementation, in the case of a SQLServer or Oracle database the following query should be adapted to the corresponding SQL dialect and provided Spatial functions:
select id, site_no, lan_fa_ty, locid from airports where ST_Contains(ST_Transform(ST_MakeEnvelope(' + BBOX.x1 + ',' + BBOX.y1 + ',' + BBOX.x2 + ',' + BBOX.y2 + ',3857),2831),geometry_spa)'
We will issue this query using the M.App Enterprise Query API in the custom script of the Custom panel. In this panel we:
In the Map panel we:
The app is comprised of just a Map panel.
Here is the app in action:
The App can be simply configured using the 1 panel and customizing it with the source code attached to this article (QueryAPI2.zip).
The approach is the same as in the sample 1. In this case we are executing the query directly within the Map panel using the coordinates of the point clicked on the map.
Here is the query definition:
select osm_id, name, type, case oneway when 1 then '✓' else '✗' end as oneway, case bridge when 1 then '✓' else '✗' end as bridge, case tunnel when 1 then '✓' else '✗' end as tunnel from roads where St_DWithin(ST_GeometryFromText(\'POINT(' + X + ' ' + Y + ')\',2831),geometry_spa,2)
We will issue this query using the M.App Enterprise Query API in the custom script of the Map panel. We: