GeoJsonData QML Type | Qt Location 6.8.0
Description: A model to represent, load and save GeoJSON documents.

- Qt 6.8
- Qt Location
- QML Types
- GeoJsonData
- Qt 6.8.0 Reference Documentation

# GeoJsonData QML Type

A model to represent, load and save GeoJSON documents. More...

Import Statement: | import QtLocation 6.8
Since: | QtLocation 6.7

- List of all members, including inherited members
- GeoJsonData is part of QML Maps Plugin.

## Properties

- model : QVariant `(since 6.7)`
- sourceUrl : QUrl `(since 6.7)`

## Methods

- bool addItem(Item item)
- void clear()
- bool open()
- bool openUrl(Url url)
- bool save()
- bool saveAs(Url url)
- void setModelToMapContents(MapView mapItemView)

## Detailed Description

The GeoJsonData element reads and writes GeoJson documents (see the Wikipedia page, RFC) from the sourceUrl. The respective data can be accessed as QVariant via the model property. The QVariant representation can be used with delegates to visualize the data or to make small modifications, e.g. adding new items with the addItem function.

New data can be stored with the save and saveAs functions.

See also QGeoJson.

## Property Documentation

model : QVariant `[since 6.7]`

A QVariant representation of the GeoJSON document that can be used to display the contents with delegates.

This property was introduced in Qt 6.7.

sourceUrl : QUrl `[since 6.7]`

The URL from which the GeoJSON document is read. Setting this property will change the model to represent the respective document.

This property was introduced in Qt 6.7.

## Method Documentation

bool addItem(Item item)

Add the item to the model of the GeoJsonData.

Returns `true` if the file was read successfully, `false` otherwise.

void clear()

Delete all items in the model of the GeoJsonData.

bool open()

Reload the content of the file at sourceUrl.

Returns `true` if the file was read successfully, `false` otherwise.

bool openUrl(Url url)

Open the GeoJson file at url and load its content. The property sourceUrl will be set to url if the file is read successfully.

Returns `true` if the file was read successfully, `false` otherwise.

bool save()

The current model of the GeoJsonData object is saved under sourceUrl.

Returns `true` if the file was saved successfully, `false` otherwise.

bool saveAs(Url url)

The current model of the GeoJsonData object is saved under url. The sourceUrl property will be set to url.

Returns `true` if the file was saved successfully, `false` otherwise.

void setModelToMapContents(MapView mapItemView)

All mapItems of mapItemView are added to the model of the GeoJsonData object. Previously stored mapItems are deleted from the model.

Returns `true` if mapItemView is set successfully, `false` otherwise.

See also addItem.