Skip to main content

Map features

The geo-fields, enable the user to define geo-objects on a MapView / GeoJSONView.

Reference

For a more technical API reference, please see the following pages:

GeoPointField - draw a point

The GeoPointField enables the user to draw a point on the map. It should be used in combination with a MapView or GeoJSONView.

import viktor as vkt


class Parametrization(vkt.Parametrization):
geo_point = vkt.GeoPointField('Draw a point')

The user input can be obtained through the params argument and can have the following values:

Expand to see all available arguments

In alphabetical order:

  • default: a default value will be prefilled

    geo_point = vkt.GeoPointField('Draw a point', default=vkt.GeoPoint(lat=51.9225, lon=4.4719))
  • description: add a tooltip with additional information

    geo_point = vkt.GeoPointField('Draw a point', description="This field represents the ...")
  • name: defines the position of the parameter in the params

    geo_point = vkt.GeoPointField('Draw a point', name="g")  # obtained using params.g
  • visible: can be used when the visibility depends on other input fields

    geo_point = vkt.GeoPointField('Draw a point', visible=vkt.Lookup("another_field"))

    See 'Hide a field' for elaborate examples.

GeoPolylineField - draw a (poly)line

The GeoPolylineField enables the user to draw a polyline on the map. It should be used in combination with a MapView or GeoJSONView.

import viktor as vkt


class Parametrization(vkt.Parametrization):
geo_polyline = vkt.GeoPolylineField('Draw a polyline')

The user input can be obtained through the params argument and can have the following values:

Expand to see all available arguments

In alphabetical order:

  • default: a default value will be prefilled

    geo_polyline = vkt.GeoPolylineField(
    'Draw a polyline',
    default=vkt.GeoPolyline(
    vkt.GeoPoint(lat=51.9225, lon=4.4719),
    vkt.GeoPoint(lat=52.3600, lon=4.8853),
    )
    )
  • description: add a tooltip with additional information

    geo_polyline = vkt.GeoPolylineField('Draw a polyline', description="This field represents the ...")
  • name: defines the position of the parameter in the params

    geo_polyline = vkt.GeoPolylineField('Draw a polyline', name="g")  # obtained using params.g
  • visible: can be used when the visibility depends on other input fields

    geo_polyline = vkt.GeoPolylineField('Draw a polyline', visible=vkt.Lookup("another_field"))

    See 'Hide a field' for elaborate examples.

GeoPolygonField - draw a polygon

The GeoPolygonField enables the user to draw a polygon on the map. It should be used in combination with a MapView or GeoJSONView.

import viktor as vkt


class Parametrization(vkt.Parametrization):
geo_polygon = vkt.GeoPolygonField('Draw a polygon')

The user input can be obtained through the params argument and can have the following values:

Expand to see all available arguments

In alphabetical order:

  • default: a default value will be prefilled

    geo_polygon = vkt.GeoPolygonField(
    'Draw a polygon',
    default=default=vkt.GeoPolygon(
    vkt.GeoPoint(lat=51.9225, lon=4.4719),
    vkt.GeoPoint(lat=52.3600, lon=4.8853),
    vkt.GeoPoint(lat=52.0908, lon=5.1216),
    )
    )
  • description: add a tooltip with additional information

    geo_polygon = vkt.GeoPolygonField('Draw a polygon', description="This field represents the ...")
  • name: defines the position of the parameter in the params

    geo_polygon = vkt.GeoPolygonField('Draw a polygon', name="g")  # obtained using params.g
  • visible: can be used when the visibility depends on other input fields

    geo_polygon = vkt.GeoPolygonField('Draw a polygon', visible=vkt.Lookup("another_field"))

    See 'Hide a field' for elaborate examples.

Visualize geo-objects on the map

The above geo-fields let the user 'draw' geo-objects, but does not actually visualize it on the map. If visualizing the geo-objects on the map is desired, this can easily be achieved by making use of the class-method on the corresponding map feature as described here.

Interact with geo-objects on the map

In addition to visualizing geo-objects, it is also possible to let the user interact with the geo-objects on the map.