javascript - Loading GeoJSON into Meteor's leaflet -
i quite new meteor. trying implement own custom version of example leaflet meteor: interactive choropleth map
it uses file import geojson data: us-states
my problem is: importing file or getting render.
what have done:
template.map.rendered = function() { var map = l.map('map').setview([37.8, -96], 5); l.tilelayer.provider('stamen.watercolor').addto(map); http.get(meteor.absoluteurl("/us-states.js"), function(err,result) { var statesdata = result.content; console.log(statesdata); var mystyle = { "fillcolor": "#487ba1", "weight": 3, "opacity": 1, "color": "#487ba1", "fillopacity": 0.1 }; var stateslayer = l.geojson(statesdata, { style: mystyle }).addto(map); }); }
#map { width: 100%; height: 100%; }
<div id="column"> {{> map}} </div> <template name="map"> <div id='map'></div> </template>
what get: uncaught error: invalid geojson object.
the variable "statedata" returns object. want render geojson data onto map. on plain html. don't know working?
the problem seems come us-states.js
file. want load data it, instead of data have variable declaration in it:
var statesdata = { "type":"featurecollection", "features": [ .... ] }
you should keep data in file , remove var statesdata =
part:
{ "type":"featurecollection", "features": [ .... ] }
Comments
Post a Comment