0

I spotted a nice D3 Map & Chart sample that is using

  • leaflet-0.5
  • d3.v3

I would like to make use of some features in the esri-leaflet package (specifically use a Vector basemap), but I believe I need to update the current sample to leaflet-1.2.0 to do this.

As soon as I switch from using leaflet-0.5 to the leaflet@1.2.0 (from the vector sample) in the header, along with the latest CSS then I get the following error in the console:

leaflet.js:5 Uncaught Error: The provided object is not a Layer.
at e.addLayer (leaflet.js:5)
at e.addTo (leaflet.points-layer.js:44)
at d3_map_vt.html:76
at d3.v3.js:2011
at Object.<anonymous> (d3.v3.js:1996)
at Object.event (d3.v3.js:504)
at XMLHttpRequest.respond (d3.v3.js:1949)

Can someone give me some pointers on how to go about updating this sample and what the cause of the above error is? Do I need to also update the d3 library as well?

I have tweaked the code for my own data here

4

1 回答 1

2

你很幸运。这个伟大的样本只需要一个小的调整就可以在 Leaflet 1.x 中运行。

// line 1 of leaflet.points-layer.js
L.PointsLayer = L.Layer.extend({ // instead of L.Class    
  includes: L.Evented.prototype, // instead of L.Mixin.Events
于 2017-08-09T21:38:03.910 回答