kekscom / osmbuildings

OSM Buildings Classic 2.5D
http://osmbuildings.org
BSD 2-Clause "Simplified" License
505 stars 141 forks source link

Can't add to l.control.layers #25

Closed denny123 closed 11 years ago

denny123 commented 11 years ago

var baseMaps; var overlayMaps; var control;

var wms = new L.TileLayer.WMS( "/geoserver/wms", { layers: "planet_osm_polygon", format: "image/png", transparent: true } );

var build = new L.BuildingsLayer().addTo(map).geoJSON(bdata).setDate(new Date(2013, 03, 01, 11, 30));

baseMaps = {"OpenStreetMap": mapnik}; overlayMaps = {"Население по районам": wms/, "3D здания": build/}; control = L.control.layers(baseMaps, overlayMaps); map.addControl(control);

ERROR: Cannot read property '_leaflet_id' of undefined?

kekscom commented 11 years ago

The last function call .setDate()does not return a valid layer. For now, break it into two statements:

var build = new L.BuildingsLayer().addTo(map);
build.geoJSON(bdata).setDate(new Date(2013, 03, 01, 11, 30));
denny123 commented 11 years ago

now after remove build(unset in control) show error: "NOT_FOUND_ERR: DOM Exception 8"...

kekscom commented 11 years ago

I don't get that exception in the reduced test environment. But buildings don't get re-added on remove -> add

I created this jsfiddle as playground. Could you try to reproduce the issue there? http://jsfiddle.net/osmbuildings/sbW36/1/

denny123 commented 11 years ago

In jsfiddle your example not working too how me: after remove - not add, and my error can see on javascript console.

kekscom commented 11 years ago

Strange. What browser are you using? Probably create a screenshot.

denny123 commented 11 years ago

screen Chrome.

kekscom commented 11 years ago

Whatever I do, I can't reproduce it. Please send me the versions of: Leaflet, OSM Buildings, Chrome you are using. Ideally I like to see the page on your server.

denny123 commented 11 years ago

This error display sometimes with not only this problem, may be leaflet script....i trying more....

denny123 commented 11 years ago

ok, now not have this error, but why after remove not add in console?

kekscom commented 11 years ago

You mean, now you DON'T have it anymore? Would make some sense as there was some async image handling done wrong - maybe causing the bug. That should be fixed by now.

Am 07.03.2013 um 07:33 schrieb denny123 notifications@github.com:

ok, now not have this error, but why after remove not add in console?

— Reply to this email directly or view it on GitHub.

denny123 commented 11 years ago

now no error: "NOT_FOUND_ERR: DOM Exception 8", but now if after remove 3D build(from consolelayers without error) i can't add...? 3D build layer not add in map. And if: var build = new L.BuildingsLayer(); build.geoJSON(bdata).setDate(new Date(2013, 03, 01, 11, 30)); then error: "Cannot call method 'geoJSON' of null"

kekscom commented 11 years ago

I just learned myself you need to do the .addTo(map) before any setStyle or setDate calls.

denny123 commented 11 years ago

ok, i hope this layer was working in controllayer.

denny123 commented 11 years ago

Any news?

kekscom commented 11 years ago

With version 0.1.8a there is a whole new version of OSM Buildings. Some possible error causes are fixed. But it's still working fine for me anyway. I was assuming that you do further checks on other code. Question is, whether the latest version is working better for you or not.

denny123 commented 11 years ago

I have version 0.1.8a(i think in CHANGELOG.md) and after delete 3Dlayer in controlpanel i cant add more.

var build = new L.BuildingsLayer().addTo(map); build.geoJSON(bdata).setDate(new Date(2013, 03, 01, 11, 30));

//baseMaps = {"OpenStreetMap": mapnik}; overlayMaps = {"WMS статистика": wms, "Векторная статистика": geojson, "Прозрачный слой": defjson, "Магазины": markers_shop, "Поликлиники": markers_doctors, "3D здания": build}; control = L.control.layers({}, overlayMaps); map.addControl(control);

kekscom commented 11 years ago

I'm not able to reproduce the issue that way. Please either set up a separate JSFiddle or point me to an URL with your project.

denny123 commented 11 years ago
OpenStreetMap ``` ``` ``` ``` ``` ``` ```
kekscom commented 11 years ago

After seeing the code: I can't test this as I don't have most of the referred files. The sheer amount of plugins and inclusions indicates the issue can be everywhere. I can't debug it for you - at least not this way. Please copy your code, remove everything except LeafletJS and OSM Buildings and retry. Ideally, set that up in JSFiddle so I can take over and help at some point.

kekscom commented 11 years ago

Hi Denny, just in case you are still using the code: I've fixed a bug which very likely caused that issue. Would be grat if you'd like to retry with latest version from master. Just be aware, there is no need for a hosted database on your side anymore. I'm still updating the docs.

denny123 commented 11 years ago

I tried load() and all working and this very comfortable(i need buildings from OSM). Thank you.