Appearance
Map GeoJSON
The {maps:add_geojson} tag pair adds GeoJSON data to the map, for use inside the {exp:reinos_maps:map} tag.

The tag
{exp:reinos_maps:map}
{maps:add_geojson}
{
"type": "Feature",
"properties": {
"name": "Coors Field",
"amenity": "Baseball Stadium",
"popupContent": "This is where the Rockies play!"
},
"geometry": {
"type": "Point",
"coordinates": [-104.99404, 39.75621]
}
}
{/maps:add_geojson}
{/exp:reinos_maps:map}Tag parameters
Below are the Tag Parameters. Those parameters can be used in the tag described above.
stroke:color
Set the stroke color.
stroke:color="#000000" [OPTIONAL]stroke:opacity
Set the stroke opacity.
stroke:opacity="1" [OPTIONAL]stroke:weight
Set the stroke weight.
stroke:weight="1" [OPTIONAL]fill:opacity
Set the fill opacity.
fill:opacity="0.4" [OPTIONAL]fill:color
Set the fill color.
fill:color="#000000" [OPTIONAL]Tagdata
Place your GeoJSON data between the tags. It must be valid JSON, otherwise it is not added and an error is logged.
When a feature has a popupContent property, it is used as the content of the popup. A name property is used as the tooltip.
{exp:reinos_maps:html_header}
{exp:reinos_maps:map fit_map:geojson="yes"}
{maps:add_geojson}
[{
"type": "Feature",
"properties": {"party": "Republican"},
"geometry": {
"type": "Polygon",
"coordinates": [[
[-104.05, 48.99],
[-97.22, 48.98],
[-96.58, 45.94],
[-104.03, 45.94],
[-104.05, 48.99]
]]
}
}, {
"type": "Feature",
"properties": {"party": "Democrat"},
"geometry": {
"type": "Polygon",
"coordinates": [[
[-109.05, 41.00],
[-102.06, 40.99],
[-102.03, 36.99],
[-109.04, 36.99],
[-109.05, 41.00]
]]
}
}]
{/maps:add_geojson}
{/exp:reinos_maps:map}Style
You can set the style of all features with the parameters. For a style per feature, use a Javascript function.
The example below uses the geojson.beforeReady event, which fires before the GeoJSON is added to the map. In it, REINOS_MAPS.setGeoJsonStyle gets a function that returns the style of each feature.
<script>
REINOS_MAPS.on('geojson.beforeReady', function(){
REINOS_MAPS.setGeoJsonStyle(function(feature) {
//your logic
return {color: "#fff"};
});
});
</script>A full example that colors the Republican and the Democrat state:
{exp:reinos_maps:html_header}
{exp:reinos_maps:map fit_map:geojson="yes"}
{maps:add_geojson}
[{
"type": "Feature",
"properties": {"party": "Republican"},
"geometry": {
"type": "Polygon",
"coordinates": [[
[-104.05, 48.99],
[-97.22, 48.98],
[-96.58, 45.94],
[-104.03, 45.94],
[-104.05, 48.99]
]]
}
}, {
"type": "Feature",
"properties": {"party": "Democrat"},
"geometry": {
"type": "Polygon",
"coordinates": [[
[-109.05, 41.00],
[-102.06, 40.99],
[-102.03, 36.99],
[-109.04, 36.99],
[-109.05, 41.00]
]]
}
}]
{/maps:add_geojson}
{/exp:reinos_maps:map}
{exp:reinos_maps:html_footer}
<script>
REINOS_MAPS.on('geojson.beforeReady', function(){
REINOS_MAPS.setGeoJsonStyle(function(feature) {
switch (feature.properties.party) {
case 'Republican': return {color: "#ff0000"};
case 'Democrat': return {color: "#0000ff"};
}
});
});
</script>