Having a truly-baffling problem with maxBounds .. profoundly Urgent!

31 views
Skip to first unread message

Mike Robinson

unread,
May 13, 2015, 12:51:20 PM5/13/15
to leafl...@googlegroups.com
If you surf here:


... you will immediately see my problem.  This is with the latest version of Leaflet (0.7.3).

We are displaying a bitmap that is 700 pixels high (coordinates [-700..0]) and 1162 pixels wide ([0..1162]), constructed using gdal2tiles.py.

We have a TileLayer that is supposed to have a bounds equal to the dimensions of the map, so that it will never display anything outside the dimensions of that map.  You can clearly see, however, that this bounds is restricting the set-of-tiles to a much smaller area.  (Zoom out to see what I mean.)

Likewise, the Map has maxBounds, and you can see that it does when you try to drag the map.  (It snaps back.)  But, once again, it's not nearly big enough and it's not positioned correctly.

I know that if I manually fiddle-with the parameters of this LatLngBounds object, I can coax it into working as it should.  But of course, that's not the point!

The source-code (in Haxe) that calculates the relevant geometry is:

                var southWestPoint      = new Point ( minX, minY );

               var northEastPoint      = new Point ( maxX, maxY );

               maxBounds                                               = new LatLngBounds(

                               leaflet.geo.crs.CRS.Simple.pointToLatLng( southWestPoint, maxZoom ),

                               leaflet.geo.crs.CRS.Simple.pointToLatLng( northEastPoint, maxZoom )

                       );


          // Now, Calculate the "center"

               centerPoint             = new Point ( minX + ((maxX - minX) / 2.0),

                                                     minY + ((maxY - minY) / 2.0)   );      


                centerLatLng = leaflet.geo.crs.CRS.Simple.pointToLatLng( centerPoint, maxZoom );


(the "center" actually doesn't matter.)  The JavaScript file used by that page is the Haxe system's output, which closely resembles the input.

Values are:  minX = 0, maxX = 1162, minY = -700, maxY = 0, minZoom = 0, maxZoom = 5.

I am absolutely stopped-dead by this problem, and have been now for several days.

You will see many trace-outputs in the console log if you go to the page.  The first log entry is for the map that you see.  For your convenience, here it is:

Campus_Map_Sept-2011: SW=Point(0, -700), NE=Point(1162, 0), maxBounds={
_southWest : LatLng(0, 0), 
_northEast : LatLng(21.875, 36.3125)
}, centerLatLng=LatLng(10.9375, 18.15625)

We are using CRS.Simple.  I have verified that this is, indeed, the function that is being called within Leaflet.

Reply all
Reply to author
Forward
0 new messages