GeoJSON is a widely-recognized standard for defining geospatial data. You can define points, lines, polygons and more, as well as take advantage of the generic properties
schema to add custom styles and pin metadata to the rendered features.
Demo
To view a quick demo of the custom GeoJSON visual, use the Echo demo app referenced on the overview page to run the input below.
After running, you should see a Custom map tab view on the run details view in Nextmv Console; clicking on this tab should display a custom map with a couple lines and several points. You can pan and zoom and click on the features to reveal the metadata.
Defining GeoJSON data
This section covers the requirements for passing your GeoJSON data for the custom visual asset to the content
property. The schema requirements for defining a custom visual asset can be found on the Overview page.
The GeoJSON data sent as a custom visual is rendered on our standard map view, which is powered by Leaflet. The map view will render the following GeoJSON types:
Point
MultiPoint
LineString
MultiLineString
Polygon
MultiPolygon
All GeoJSON types except for Point
are rendered using Leaflet’s geoJSON
method. Leaflet’s GeoJSON documentation is a good resource for learning what else you can do with the standard GeoJSON schema beyond just standard rendering (e.g. adding custom styles to features).
GeoJSON Point
features are passed through the supercluster library to help with browser rendering. That is, the points are extracted from your GeoJSON data and then rendered with a clustering engine by default. However, note that you can still customize the individual point styles as outlined in Leaflet’s GeoJSON documentation.
Example rendering of about 1,500 points
The custom data that is passed to content
must be in the form of a single GeoJSON FeatureCollection
type. And the feature collection’s features
property is where the GeoJSON data is defined. So a GeoJSON custom visual asset would look like this:
Currently you can only define one map view per custom visual. If you need multiple maps it is recommended to either combine the GeoJSON data and distinguish the features with different styles or just create multiple custom visuals for as many maps as you need.
Extending GeoJSON schema
The standard GeoJSON schema can be extended for Nextmv’s custom map visual with two properties style
and metadata
defined in the GeoJSON properties
object. (Note: The properties
key in GeoJSON schema is reserved for arbitrary data that parsers can choose to use or not.)
Custom style
As mentioned prior, custom styles can be applied to features by defining them in property.style
:
Which custom styles and how they are applied is decided by Leaflet’s rendering engine. See Leaflet’s GeoJSON docs for more information.
Adding metadata in popups
You can also add viewable metadata to a feature by adding the data to the properties.metadata
as an array of objects each with a key
and value
property. The key
property must be a string and the value
property must be a string or number.
If a feature is clicked then a popup will appear with the metdata information displayed.