v-leaflet zoomToExtent

Hi to all.

I’m a a beginner in v-leaflet and I’m trying to show all markers in a map.

I wrote something like:


Point mapPoints = new Point[2]
;
mapPoints[0]
= new Point(latPoint1, longPoint1);
mapPoints[1]
= new Point(latPoint2, longPoint2);
Bounds mapBounds = new Bounds(mapPoints);
map.setCenter(mapBounds);
map.zoomToExtent(mapBounds);

However, zoomToExtent(…) doesn’t seem to get any affect: browser always shows a map correctly centered, but with a too high level of zoom, where points cannot be seen. If I click some times on the “-” icon of the UI (so decreasing zoom level) I can see my points. If I comment zoomToExtent, nothing changes.

Please, can anyone help me?

Thanks in advance.
Alessandro

Hi,

I’d guess the underlaying leaflet has cached bad size for the component. Could you fill an issue to the v-leaflet project page and provide a small test case for the issue? I’ll try to find some to for the project tomorrow so I could take a look at this.

cheers,
matti

Hi,

There is now new version (0.0.9) that has fix for possibly related issue. If it still doesn’t work with that version, please post that test case to the project page.

cheers,
matti

I posted a working example on project page in GitHub. I tested it with version 0.0.9, but the problem seems still there.

I posted a working example on project page in GitHub. I tested it with version 0.0.9, but the problem seems still there.

Thanks.
Alessandro

Yes I’ve had this issue (see https://github.com/mstahv/v-leaflet/issues/9)

I fixed the issue with a quick hack in the v-leaflet project … see:

https://github.com/willtemperley/v-leaflet/commit/7ff453e5bd3383c68947f85dbb9b6c7a6cb0e58e