Unofficial Content

The concept of a Geometry Layer refers to a set of Geography data (based on the Geography, Geopoint, Geoline, or Geopolygon data types) grouped in a logical way, to be displayed with the same style (color, width, etc.) in a Panel Grid whose Control Type property is set to Maps.

For example, to show information about an urban area, including:

Streets (Geolines)
Avenues (Geolines)
Neighborhoods (GeoPolygons)
Municipalities (GeoPolygons)
Educational centers (GeoPoints)

You can show only Avenues and/or distinguish Streets from Avenues by color or thickness.

Scope

Controls: Grid (Control Type: Maps)
Generators: Android, Apple

Description

You can define different Geometry Layers to configure their specific display properties (color, width, icon, etc.) and whether to show them or not.

For example, in the map below:

Image Geolayer1

The following Geometry Layers are displayed for a city area:

  1. Avenue
  2. BikeWay 
  3. Electric BusWay
  4. Train

Each one is identified by its style (Icon, Color, Width) and it is possible to choose whether to display each layer or not.

Consider the UrbanArea Transaction object with the following attributes:

UrbanArea
{
 UrbanAreaId* - Numeric
 UrbanAreaGeo - Geography
 UrbanAreaGeoLayerID - Character
 UrbanAreaGeoLayerWayType - Character
}

Assume the following data is stored in the UrbanArea table:

image_2023329145530_1_png

How to define Geometry Layers?

Geometry Layers can be defined in two ways:

1) Configuring the Geometry Layer Id Attribute property and the Location Attribute property of the Panel Grid whose Control Type property is set to Maps.

2) Loading a KML file.

1) In the shown example, for the Panel Grid whose Control Type property is set to Maps, just configure:

A Map like the one shown above should be displayed. 

2) The LoadKmlLayer method draws geometries from a KML file that contains the style definition.

Look at the following code:

&LayerData = "<kml xmlns="http://www.opengis.net/kml/2.2">"
&LayerData += "<Placemark> <name>Trabajo</name> <description>LATU</description>"
&LayerData += "<Point> <coordinates>-56.2</coordinates> </Point> "
&LayerData += "</Placemark> </kml>"
MapGrid.LoadKmlLayer("Work",&LayerData,false)
Note: The ID or class visibility cannot be set.


How to draw all Geometry Layers with the same color?

The style of the geometries is given by the following Grid control Class properties:

image_202332913913_1_png

The Class property of the Grid allows configuring all the map geographies with the same color.


How to display each Geometry Layer with a different color?

To display each Geometry Layer with another color, in a Grid with a Base Table something similar to the following code should be defined in the Load event:

Event load 
    Do case 
         Case UrbanAreaGeoLayerID= "Avenue"
                   GeoLayerAtt.Class = "Orange"
         Case UrbanAreaGeoLayerID= "BikeWay"
 ​​​​​                   GeoLayerAtt.Class = "Green"
         ....
     endcase
endevent 


How to hide/show a Geometry Layer?

Use the SetLayerVisible method as shown in the following samples:

MapGrid.SetLayerVisible(UrbanAreaGeoLayerID, true)

MapGrid.SetLayerVisible(UrbanAreaGeoLayerID, false)


How to add a Geography to an existing Geometry Layer?

 1. If the Grid has an associated Base Table, it is automatic. Adding a record to the GeoLayer table is enough. 
 2.  Using the DrawGeography method and its new Layer ID parameter, i.e:

&GeographyId =  MapGrid.DrawGeography(&geography, "class",  UrbanAreaGeoLayerID)


How to delete a Geometry from a Geometry Layer?

 1. If the Grid has an associated Base Table, clear the Layer ID attribute for that record.

 2. Directly clear that geography with the Clear method using the ID.

  Clear(GeographyId)

To move it to another layer or leave it without an associated layer, redraw it using the DrawGeography method and clear the Layer ID parameter.

&GeographyId =  MapGrid.DrawGeography(&geography, "class",  "")


How to draw geometries of a layer with different colors?

To differentiate each Geometry layer with colors too, something similar to case 2 must be done by adding the necessary conditions.
For example, if you have the Walking or Drive paths and want to differentiate them, program it as follows:

Event load 
    Do case 
         Case UrbanAreaGeoLayerID= "BikeWay" and UrbanAreaGeoLayerWayType = "BikeTwoWay"
                   GeoLayerAtt.Class= "GreenSolidLine"
        Case UrbanAreaGeoLayerID= "BikeWay" and UrbanAreaGeoLayerWayType = "Street 3km" 
                   GeoLayerAtt.Class= "GreenDottedLine"
         ....
     endcase

endevent 

Where:
BlueWidth5 is a class defined for lines, based on SDMapRoute, with blue color and width 5.

BlueWidth1 property is a class defined for lines, based on SDMapRoute, with blue color and width 1 property.

Lists of properties and methods involved

Properties

Property Values Description
Geometry Layer Id Attribute property Attribute or variable of Character / Numeric data type. Configures the attribute or variable that determines the Logical layer to which the Geography specified in the LocationAttribute or LocationAttribute Field Specifier belongs.
Location Attribute property Attribute or variable of Geography / GeoPolygon / GeoLine / GeoPoint type data type, Configures the attribute or variable of the grid that determines the geographies to draw.
Geometry Layer Id Field Specifier property SDT item that determines the Logical layer to which the Geography belongs.

It has the same goal as Geometry Layer Id Attribute property but the grid is bound to an SDT. 

Location Attribute Field Specifier SDT item that determines the geography to draw. It has the same goal as Location Attribute property but the grid is bound to an SDT. 

Note: Geographies are not associated with any layer by default if a Geometry Layer Id Attribute property is not assigned.

Methods

Method Parameter Description
GetLayerVisible LayerID: Character

Returns a Boolean value indicating whether the given Geometry layer is shown on the map.

SetLayerVisible LayerID: Character, Visible: Boolean

Shows or hides a given layer using its identifier (of character type).

DrawGeography Geography: Geography, Class: Character, LayeriD: Character

Draws a geography and specifies the layer.

LoadLayer    
LoadKmlLayer LayerID character, LayerData Longvarchar, AllowSelection boolean Loads the specified layer on the Map (Grid) in KML format.
LoadKMLLayerFile LayerId character, LayerDataPath String , AllowSelection boolean Loads on the Map (Grid) the layer specified by a file in KML format.

 

Availability

Since GeneXus 17 upgrade 4.

Last update: April 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant