From 408e181d1ebf2da2b14921beaedbfcd2fb5f32ee Mon Sep 17 00:00:00 2001 From: Steve McDonald Date: Mon, 2 May 2016 09:43:32 -0400 Subject: [PATCH] #10 initial Angular 1.5 code I verified this code works in a very basic Angular app. In it, my main html page included all the needed JavaScript libraries. --- leafletSolrAngularComponent.js | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 leafletSolrAngularComponent.js diff --git a/leafletSolrAngularComponent.js b/leafletSolrAngularComponent.js new file mode 100644 index 0000000..c06f619 --- /dev/null +++ b/leafletSolrAngularComponent.js @@ -0,0 +1,52 @@ + +/** + +using the leaflet-solr-heatmap library in Angular 1.5 + +we must tell Angular about our component +this example uses the variable leafletSolrComponentOptions which is declared below + + + + +to add a leaflet map and heatmap layer to a web page, we declare a leaflet-solr-component tag as follows: + + + + +*/ + +// the component wrapper around the leaflet-solr-heatmap JavaScript library +// leafletSolrComponentOptions should be passed to the .component function as illustrated above +// not that I have little experience with Angular +var map; +var leafletSolrComponentOptions = +{ + bindings: {theTitle: '@', mapdivid: '@', solrUrl: '@', options: '@'}, + transclude: true, + controller: function() + {this.$onInit = function() + { + console.log('in leafletSolr onInit function, map div id:',this.mapdivid); + console.log('theTitle', this.theTitle); + map = L.map(this.mapdivid).setView([0, 0], 1); + + var layer = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png', { + attribution: '© OpenStreetMap contributors, © CartoD\ +B' + }).addTo(map); + var options = JSON.parse(this.options); + solr = L.solrHeatmap(this.solrUrl, options); + solr.addTo(map); + }; + }, + template: '

hello map

' +}; \ No newline at end of file