var popup = feature.popup;
var popupPos = null;
- if (sypSettings.popupNearfeature) {
- popupPos = feature.geometry.getBounds().getCenterLonLat();
- } else {
- popupPos = SYP.Utils.brCorner(map, 8);
+ switch (sypSettings.popupPos) {
+ case 0:
+ popupPos = feature.geometry.getBounds().getCenterLonLat();
+ break;
+ case 1:
+ popupPos = SYP.Utils.tlCorner(map, 8);
+ break;
+ case 2:
+ popupPos = SYP.Utils.trCorner(map, 8);
+ break;
+ case 3:
+ popupPos = SYP.Utils.brCorner(map, 8);
+ break;
+ case 4:
+ popupPos = SYP.Utils.blCorner(map, 8);
+ break;
+ default:
+ popupPos = SYP.Utils.brCorner(map, 8);
+ break;
}
// we cannot reuse popup; we need to recreate it in order for IE
},
Utils: {
+ tlCorner: function(map, margin) {
+ var bounds = map.calculateBounds();
+ var corner = new OpenLayers.LonLat(bounds.left, bounds.top);
+ var cornerAsPx = map.getPixelFromLonLat(corner);
+ cornerAsPx = cornerAsPx.add( +margin, +margin);
+ return map.getLonLatFromPixel(cornerAsPx);
+ },
+
+ trCorner: function(map, margin) {
+ var bounds = map.calculateBounds();
+ var corner = new OpenLayers.LonLat(bounds.right, bounds.top);
+ var cornerAsPx = map.getPixelFromLonLat(corner);
+ cornerAsPx = cornerAsPx.add( -margin, +margin);
+ return map.getLonLatFromPixel(cornerAsPx);
+ },
+
brCorner: function(map, margin) {
var bounds = map.calculateBounds();
var corner = new OpenLayers.LonLat(bounds.right, bounds.bottom);
var cornerAsPx = map.getPixelFromLonLat(corner);
cornerAsPx = cornerAsPx.add( -margin, -margin);
- corner = map.getLonLatFromPixel(cornerAsPx);
- return corner;
+ return map.getLonLatFromPixel(cornerAsPx);
+ },
+
+ blCorner: function(map, margin) {
+ var bounds = map.calculateBounds();
+ var corner = new OpenLayers.LonLat(bounds.left, bounds.bottom);
+ var cornerAsPx = map.getPixelFromLonLat(corner);
+ cornerAsPx = cornerAsPx.add( +margin, -margin);
+ return map.getLonLatFromPixel(cornerAsPx);
},
/* minimum bounds rectangle containing all feature locations.