User Tools

Site Tools


samples:samples:fields

Table of Contents

Fields sample

Documentation | Samples | Fields

Summary

Fields Sample - Demonstrates how to use field (attribute) properties of a layer.

Description

What the sample shows:

  • Defining custom attribute fields on in-memory vector layer via AddField
  • Field properties: name, type (TGIS_FieldType), width, decimal precision
  • Writing field values to individual shapes via TGIS_Shape.SetField
  • Data-driven rendering using “FIELD:<name>” expression syntax
  • Per-attribute colour assignment via field values
  • Per-attribute size control via field values
  • Per-attribute rotation via field values
  • Label text from field values
  • Label positioning from field values
  • Exposing layer attribute table via TGIS_DataSet
  • Displaying attributes in DataGridView grid control
  • Interactive grid editing with automatic map refresh
  • Lock types: Projection (layer CS) vs Extent (world coordinates)

This sample illustrates use of:

Name Description
TGIS_LayerVector.CreateShapeCreates a new editable shape instance from the specified TGIS_Shape descendant class.
TGIS_LayerVector.ParamsReturns the vector rendering parameters object for the layer.
TGIS_LayerVector.AddFieldAdds a new attribute field definition to the layer schema.
TGIS_Shape.AddPartStarts a new part in the shape geometry.
TGIS_Shape.AddPointAdds a 2D vertex to the current part of the shape.
TGIS_Shape.SetFieldSets the value of a field for this shape.
TGIS_DataSet.OpenOpen the dataset for shapes from a vector layer filtered by extent, using an RTree when available.

Code

This sample is available on the following platforms (click to view the source code on GitHub):

2026/09/21 00:22

Page Tools