diff --git a/editions/geospatialdemo/tiddlers/Features.tid b/editions/geospatialdemo/tiddlers/Features.tid new file mode 100644 index 000000000..59c9b14cc --- /dev/null +++ b/editions/geospatialdemo/tiddlers/Features.tid @@ -0,0 +1,14 @@ +title: GeoFeatures +tags: $:/tags/GeospatialDemo + +This is a list of all the tiddlers containing ~GeoJSON feature collections in this wiki (identified by the tag <>). A ~GeoJSON feature collection is a list of features, each of which consists of a geometry and associated metadata. + + diff --git a/editions/geospatialdemo/tiddlers/HelloThere.tid b/editions/geospatialdemo/tiddlers/HelloThere.tid index d54d47eac..2f01b2fa8 100644 --- a/editions/geospatialdemo/tiddlers/HelloThere.tid +++ b/editions/geospatialdemo/tiddlers/HelloThere.tid @@ -12,16 +12,16 @@ This demo requires that the API keys needed to access external services be obtai !! Demos -* Visit the ~GeoLayers and ~GeoMarkers tabs to see the data loaded into this wiki +* Visit the ~GeoFeatures and ~GeoMarkers tabs to see the data loaded into this wiki * Click on a link to a layer or marker to open the corresponding tiddler that includes a map * Use the Flickr tab to retrieve geotagged photographs from Flickr * Visit a ~GeoMarker tiddler and use the "Call ~TravelTime" button to calculate an isochrone from that location using the ~TravelTime API -! Map Showing All Layers and Markers +! Map Showing All Features and Markers <$geomap markers="[all[tiddlers+shadows]tag[$:/tags/GeoMarker]]" - layers="[all[tiddlers+shadows]tag[$:/tags/GeoLayer]]" + features="[all[tiddlers+shadows]tag[$:/tags/GeoFeature]]" state=<> /> diff --git a/editions/geospatialdemo/tiddlers/Layers.tid b/editions/geospatialdemo/tiddlers/Layers.tid deleted file mode 100644 index c2b1d0f45..000000000 --- a/editions/geospatialdemo/tiddlers/Layers.tid +++ /dev/null @@ -1,14 +0,0 @@ -title: GeoLayers -tags: $:/tags/GeospatialDemo - -This is a list of all the tiddlers containing ~GeoJSON layers in this wiki (identified by the tag <>). A ~GeoJSON layer identifies a region of the surface of the earth via a series of polygons defined as lines between consecutive points specified via latitude and longitude (and optional altitude). ~GeoJSON layers may also contain associated metadata in JSON format. - -
    -<$list filter="[all[shadows+tiddlers]tag[$:/tags/GeoLayer]sort[caption]]"> -
  • -<$link> -<$view field="caption"><$view field="title"/> - -
  • - -
diff --git a/editions/geospatialdemo/tiddlers/cascades/ViewTemplateBodyFilters.tid b/editions/geospatialdemo/tiddlers/cascades/ViewTemplateBodyFilters.tid index 0a141e502..d7688f9c0 100644 --- a/editions/geospatialdemo/tiddlers/cascades/ViewTemplateBodyFilters.tid +++ b/editions/geospatialdemo/tiddlers/cascades/ViewTemplateBodyFilters.tid @@ -2,5 +2,5 @@ title: $:/plugins/geospatial/demo/ViewTemplateBodyFilters tags: $:/tags/ViewTemplateBodyFilter list-before: $:/config/ViewTemplateBodyFilters/stylesheet -[tag[$:/tags/GeoLayer]then[ui/geolayer]] +[tag[$:/tags/GeoFeature]then[ui/geofeature]] [tag[$:/tags/GeoMarker]then[ui/geomarker]] diff --git a/editions/geospatialdemo/tiddlers/features/canada-census-subdivision-millesime.geojson.meta b/editions/geospatialdemo/tiddlers/features/canada-census-subdivision-millesime.geojson.meta index 3f7b36369..dcdc2ace2 100644 --- a/editions/geospatialdemo/tiddlers/features/canada-census-subdivision-millesime.geojson.meta +++ b/editions/geospatialdemo/tiddlers/features/canada-census-subdivision-millesime.geojson.meta @@ -1,5 +1,5 @@ title: $:/geospatialdemo/features/canada-census-subdivision-millesime caption: Canada Census Subdivisions Millesime type: application/json -tags: $:/tags/GeoLayer +tags: $:/tags/GeoFeature color: #f8f diff --git a/editions/geospatialdemo/tiddlers/features/us-states.geojson.meta b/editions/geospatialdemo/tiddlers/features/us-states.geojson.meta index 00534e40e..76edf9be9 100644 --- a/editions/geospatialdemo/tiddlers/features/us-states.geojson.meta +++ b/editions/geospatialdemo/tiddlers/features/us-states.geojson.meta @@ -1,5 +1,5 @@ title: $:/geospatialdemo/features/us-states caption: US State Boundaries type: application/json -tags: $:/tags/GeoLayer +tags: $:/tags/GeoFeature color: #88f diff --git a/editions/geospatialdemo/tiddlers/ui/geofeature.tid b/editions/geospatialdemo/tiddlers/ui/geofeature.tid new file mode 100644 index 000000000..905c9dec5 --- /dev/null +++ b/editions/geospatialdemo/tiddlers/ui/geofeature.tid @@ -0,0 +1,38 @@ +title: ui/geofeature + +\define create-intersection() +<$let + intersectLayer={{{ =[get[text]] =[get[text]] +[geointersect[]] }}} +> + <$action-createtiddler $basetitle="$:/temp/_IsochroneLayer" text={{{ [] }}} tags="$:/tags/GeoFeature" caption={{{ [addsuffix[ intersected with ]addsuffix] }}}/> + +\end + +!! Mapped + + +<$geomap + features="[]" + state=<> +/> + +!! Intersect with other features + +<$let + captionThisFeature={{{ [get[caption]else] }}} +> +
    +<$list filter="[all[shadows+tiddlers]tag[$:/tags/GeoFeature]sort[caption]] -[]" variable="otherFeature"> +<$let + captionOtherFeature={{{ [get[caption]else] }}} +> +
  • +<$link to=<>><$transclude tiddler=<> field="caption"><$view tiddler=<> field="title"/> +<$button actions=<>> +Create intersection + +
  • + + +
+ diff --git a/editions/geospatialdemo/tiddlers/ui/geolayer.tid b/editions/geospatialdemo/tiddlers/ui/geolayer.tid deleted file mode 100644 index 70502f82f..000000000 --- a/editions/geospatialdemo/tiddlers/ui/geolayer.tid +++ /dev/null @@ -1,38 +0,0 @@ -title: ui/geolayer - -\define create-intersection() -<$let - intersectLayer={{{ =[get[text]] =[get[text]] +[geointersect[]] }}} -> - <$action-createtiddler $basetitle="$:/temp/_IsochroneLayer" text={{{ [] }}} tags="$:/tags/GeoLayer" caption={{{ [addsuffix[ intersected with ]addsuffix] }}}/> - -\end - -!! Mapped - - -<$geomap - layers="[]" - state=<> -/> - -!! Intersect with other layers - -<$let - captionThisLayer={{{ [get[caption]else] }}} -> -
    -<$list filter="[all[shadows+tiddlers]tag[$:/tags/GeoLayer]sort[caption]] -[]" variable="otherLayer"> -<$let - captionOtherLayer={{{ [get[caption]else] }}} -> -
  • -<$link to=<>><$transclude tiddler=<> field="caption"><$view tiddler=<> field="title"/> -<$button actions=<>> -Create intersection - -
  • - - -
- diff --git a/editions/geospatialdemo/tiddlers/ui/geomarker.tid b/editions/geospatialdemo/tiddlers/ui/geomarker.tid index 1dce39e29..c320bf311 100644 --- a/editions/geospatialdemo/tiddlers/ui/geomarker.tid +++ b/editions/geospatialdemo/tiddlers/ui/geomarker.tid @@ -10,7 +10,7 @@ title: ui/geomarker <$action-setfield $tiddler="$:/temp/_Result" text=<>/> <$action-setfield $tiddler="$:/temp/_Headers" text=<>/> <$list filter="[compare:number:gteq[200]compare:number:lteq[299]]" variable="ignore"> -<$action-createtiddler $basetitle="$:/temp/_IsochroneLayer" text={{{ [] }}} tags="$:/tags/GeoLayer" caption={{{ [get[caption]elseaddprefix[Travel time from ]] }}}/> +<$action-createtiddler $basetitle="$:/temp/_IsochroneLayer" text={{{ [] }}} tags="$:/tags/GeoFeature" caption={{{ [get[caption]elseaddprefix[Travel time from ]] }}}/> \end @@ -88,13 +88,13 @@ title: ui/geomarker -!! GeoLayer Lookups +!! GeoFeature Lookups <$let thisLocation={{{ [geopoint{!!long},{!!lat}] }}} >
    -<$list filter="[all[shadows+tiddlers]tag[$:/tags/GeoLayer]sort[caption]]"> +<$list filter="[all[shadows+tiddlers]tag[$:/tags/GeoFeature]sort[caption]]">
  • <$text text={{{ [get[caption]] :else[] }}}/> -- <$text text={{{ [geolookup{!!text}] }}}/> diff --git a/plugins/tiddlywiki/geospatial/docs/geomap.tid b/plugins/tiddlywiki/geospatial/docs/geomap.tid index fd0c5ea42..2b89ba65b 100644 --- a/plugins/tiddlywiki/geospatial/docs/geomap.tid +++ b/plugins/tiddlywiki/geospatial/docs/geomap.tid @@ -54,11 +54,11 @@ The following attributes are supported: <$testcase> <$data title="Description" - text="Map with geolayer" + text="Map with geofeature" /> <$data title="Layer" - tags="$:/tags/GeoLayer" + tags="$:/tags/GeoFeature" type="application/json" color="red" text="""{ @@ -66,7 +66,7 @@ The following attributes are supported: "features": [ { "type": "Feature", - "id": "An example geolayer feature", + "id": "An example geofeature feature", "properties": { "custom": "A custom property of this feature" }, @@ -87,7 +87,7 @@ The following attributes are supported: }"""/> <$data title="Output" text="""<$geomap state=<> - layers="[all[tiddlers+shadows]tag[$:/tags/GeoLayer]]" + features="[all[tiddlers+shadows]tag[$:/tags/GeoFeature]]" /> """/> <$data $tiddler="$:/plugins/tiddlywiki/geospatial"/> diff --git a/plugins/tiddlywiki/geospatial/widgets/geomap.js b/plugins/tiddlywiki/geospatial/widgets/geomap.js index 21a62bc2d..3506ba3cc 100644 --- a/plugins/tiddlywiki/geospatial/widgets/geomap.js +++ b/plugins/tiddlywiki/geospatial/widgets/geomap.js @@ -71,7 +71,7 @@ GeomapWidget.prototype.renderMap = function(domNode) { }); // Add scale $tw.Leaflet.control.scale().addTo(this.map); - // Listen for pan and zoom events + // Listen for pan and zoom events and update the state tiddler this.map.on("moveend zoomend",function(event) { if(self.geomapStateTitle) { var c = self.map.getCenter(), @@ -79,6 +79,7 @@ GeomapWidget.prototype.renderMap = function(domNode) { long = "" + c.lng, zoom = "" + self.map.getZoom(), tiddler = self.wiki.getTiddler(self.geomapStateTitle); + // Only write the tiddler if the values have changed if(!tiddler || tiddler.fields.lat !== lat || tiddler.fields.long !== long || tiddler.fields.zoom !== zoom) { self.wiki.addTiddler(new $tw.Tiddler({ title: self.geomapStateTitle, @@ -89,19 +90,25 @@ GeomapWidget.prototype.renderMap = function(domNode) { } } }); - // Track the geolayers filter - this.trackerGeoLayersFilter = new FilterTracker({ + // Track the geofeatures filter + this.trackerGeoFeaturesFilter = new FilterTracker({ wiki: this.wiki, widget: this, - filter: this.geomapLayerFilter, + filter: this.geomapFeaturesFilter, enter: function(title,tiddler) { var text = (tiddler && tiddler.fields.text) || "[]", - layer = $tw.Leaflet.geoJSON($tw.utils.parseJSONSafe(text,[]),{ + geoJson = $tw.utils.parseJSONSafe(text,[]), + layer = $tw.Leaflet.geoJSON(geoJson,{ style: function(geoJsonFeature) { return { color: (tiddler && tiddler.getFieldString("color")) || "yellow" } }, + pointToLayer: function(geoJsonPoint,latlng) { + return L.circleMarker(latlng,{ + radius: 8 + }); + }, onEachFeature: function(feature,layer) { if(feature.properties) { layer.bindPopup(JSON.stringify(feature.properties,null,4)); @@ -162,8 +169,8 @@ Compute the internal state of the widget */ GeomapWidget.prototype.execute = function() { this.geomapStateTitle = this.getAttribute("state"); - this.geomapLayerFilter = this.getAttribute("layers"); this.geomapMarkerFilter = this.getAttribute("markers"); + this.geomapFeaturesFilter = this.getAttribute("features"); }; /* @@ -172,7 +179,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of GeomapWidget.prototype.refresh = function(changedTiddlers) { var changedAttributes = this.computeAttributes(); // Refresh entire widget if layers or marker filter changes - if(changedAttributes.layers || changedAttributes.markers || changedAttributes.state) { + if(changedAttributes.features || changedAttributes.markers || changedAttributes.state) { this.refreshSelf(); return true; } @@ -184,7 +191,7 @@ GeomapWidget.prototype.refresh = function(changedTiddlers) { this.setMapView(); } // Check whether the layers or markers need updating - this.trackerGeoLayersFilter.refresh(changedTiddlers); + this.trackerGeoFeaturesFilter.refresh(changedTiddlers); this.trackerGeoMarkersFilter.refresh(changedTiddlers); // No children to refresh return false;