I try to make a map using a TMS layer and a Boxes layer.
My map is built like this :
`var get_my_url = function (bounds) {
var res = this.map.getResolution();
var x = Math.round ((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
var y = Math.round ((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
var zoom = this.map.getZoom();
var path = '433-' + zoom + "-" + x + "-" + y + "." + this.type;
var url = this.url;
if (url instanceof Array) {
url = this.selectUrl(path, url);
}
return url + path;
}
var maxSize = 3872;
var mapHeight = 2592;
var tileSize = 256;
var options = {
maxExtent: new OpenLayers.Bounds(0,0,maxSize,maxSize),
maxResolution: maxSize / tileSize,
numZoomLevels: 5
};
var map = new OpenLayers.Map(
'map',
options
);`
My TMS layer is built like that :
`var layer = new OpenLayers.Layer.TMS(
'Aerial',
'<?php print site_url(); ?>/wp-content/uploads/map-tiles/',
{
type: 'png',
getURL: get_my_url,
layername: "basic",
isBaseLayer: true
}
);`
And finally, my Boxes layer is built like that :
`var bounds = new OpenLayers.Bounds(<?php print $box_x ?>, <?php print $box_y ?>, <?php print $box_x + $box_w ?>, <?php print $box_y + $box_h ?>);
box = new OpenLayers.Marker.Box(bounds);
box.events.register("click", box, function (e) {
this.setBorder("yellow");
});
var boxes = new OpenLayers.Layer.Boxes(
'Boxes',
{
layername: "juzbox",
isBaseLayer: false
}
);
boxes.addMarker(box);`
Now, I just add the layers to my map and setCenter on my map like :
`map.addLayers([layer, boxes]);
var lonlat = new OpenLayers.LonLat(maxSize/2, maxSize-(mapHeight/2));
lonlat.transform(map.displayProjection, map.baseLayer.projection);
map.setCenter(lonlat, 2);`
My problem is that my layers are not superposed but the second is under the first...
Need some help !!
Wow !! One day and a half to solve this... I think I'm just stupid sometimes... :)
Note for later : 0,0 is the bottom-left of the map, not the top-left !!!
So the problem was just in the bounds of boxes layer.
And it works... take a look at the exemple