Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add id to GeoJson #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ This tag block takes in 1 positional argument, a JSON object. This object can sp
{}
{% endleaflet_map %}

You can place any number of "leafet items" inbetween the `leaflet_map` tag blocks. At minimum, there must at least be an empty object `{}` in between the tag blocks, or else the map won't draw at all. Leaflet items include markers, geometries, geojson, features, popups, etc. Each leaflet item tag also takes in a single JSON object positional argument. In this example, we will be drawing 1 marker and 1 Polygon on a map.
You can place any number of "leafet items" inbetween the `leaflet_map` tag blocks. At minimum, there must at least be an empty object `{}` in between the tag blocks, or else the map won't draw at all. Leaflet items include markers, geometries, geojson, features, popups, etc. Each leaflet item tag also takes in a single JSON object positional argument. If an `id` key is present inside the `properties` object, its content will be used as the id of the ̀<path>` tag which represent the geojson element on the map. In this example, we will be drawing 1 marker and 1 Polygon on a map.

{% raw %}
```liquid
Expand All @@ -65,7 +65,8 @@ You can place any number of "leafet items" inbetween the `leaflet_map` tag block
{% leaflet_geojson {
"type": "Feature",
"properties": { "popupContent": "The whole state of North Dakota",
"href": "https://nd.gov" },
"href": "https://nd.gov",
"id": "area-north-dakota" },
"geometry": {
"type": "Polygon",
"coordinates": [[
Expand All @@ -89,7 +90,8 @@ You can place any number of "leafet items" inbetween the `leaflet_map` tag block
{% leaflet_geojson {
"type": "Feature",
"properties": { "popupContent": "The whole state of North Dakota",
"href": "https://nd.gov" },
"href": "https://nd.gov",
"id": "area-north-dakota" },
"geometry": {
"type": "Polygon",
"coordinates": [[
Expand Down
6 changes: 5 additions & 1 deletion lib/jekyll-leaflet/leaflet-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@
}

geojson.addTo(map);


for(var i=0; i<layers.length; i++){
if(layers[i].feature.properties.id)
layers[i]._path.id = layers[i].feature.properties.id;
}
}

function _processLeafletItem(leafletItem, map){
Expand Down