Closed soli004 closed 6 years ago
This is the index file
` <!DOCTYPE html>
GeoJSON may be a protected name. Have you tried to rename your var ?
I would firstly recommend adding a head and body block to your HTML and moving all of your script tags to the end of the
block, making sure Leaflet is loaded in first. It also looks like perhaps you load in another Leaflet by accident via<script src="libs/leaflet-src.js"></script>
. Finally got it fixed... :)
How? It will help others if you can give more details.
Actually the issue went away when I removed the second leaflet as JamesMilnerUK suggested and I also did not use GeoJson as manuamador comment on. I did also remove awesome fonts scripts as a start, tried to remove as much as I could and start build up from there. This is the changes for the vector grid part...
`var new_polygon = new L.layerGroup();
$.getJSON("../data/area.geojson", function(json) {
var vectorGrid = L.vectorGrid.slicer(json, {
maxZoom: 20,
rendererFactory: L.svg.tile,
vectorTileLayerStyles: {
sliced: {
weight: 4,
color: 'black',
opacity: 0.8,
fill: true,
stroke: true,
fillOpacity: 0
}
},
interactive: true,
})
.on('click', function(e) {
var properties = e.layer.properties;
L.popup()
.setContent(
"<b>Name</b>: " + properties.name +
"<br><b>Sum</b>: " + properties.sum + " st" +
"<br><b>AreaID</b>: " + properties.areaID)
.setLatLng(e.latlng)
.openOn(map);
})
vectorGrid.addTo(new_polygon)
}) `
I have this issue when using Leaflet.draw together with Leaflet.VectorGrid.
Everything works fine except when I put in this into index.html as a test for using VectorGrid I get this error "Uncaught TypeError: Cannot read property 'slicer' of undefined". How to solve this?
` var geojson = {"type":"FeatureCollection","features":[{"type":"Feature","properties":{"Name":"test","Number":2.25,"Size":45},"geometry":{"type":"Point","coordinates":[59.5,14.5]}}]}