[OpenLayers-Users] map is there but won't display
Garey Mills
gmills at library.berkeley.edu
Fri Aug 2 11:03:45 PDT 2013
Hello - I have a web app that has to open a popup window and display an
image as an OpenLayer map. The image is not georeferenced, but I do have
the pixel height and width, which I am using to create a Bounds object. I
have pulled the code out of the larger application and include it below
The problem is that the map div does not render in the window. If I
debug with Firebug, I can see the tiled image written into the appropriate
div, and mousing over the page I can see notional boxes were the image
should display. I can also see the image when I mouse over the div code in
the debug window.
Here is the relevant code. I am including jquery-1.6.4 and
OpenLayers-2.13.1 in the page. The page can be seen at
http://linuxdev.lib.berkeley.edu:90/frameContent.html
if (typeof org == 'undefined'){
org = {};
} else if (typeof org != "object"){
throw new Error("org already exists and is not an object");
}
org.unGeoreferencedHelper = {
image_points: { maxx: null, maxy: null, minx: null, miny: null
},
success: function(data, status, jqXHR) {
try {
this.image_points.maxx = data.maxx;
this.image_points.maxy = data.maxy;
this.image_points.minx = data.minx;
this.image_points.miny = data.miny;
} catch(e) {
alert(e);
}
try {
var bounds = new OpenLayers.Bounds(0,
this.image_points.miny,
this.image_points.maxx,
0);
} catch(e) {
alert(e);
}
// alert("Bounds: " + bounds.toString());
var options = { controls: [],
maxExtent: bounds,
maxResolution: 32,
numZoomLevels: 6,
projection: "EPSG:404000",
units: "m" };
// allowOverlays: true };
var map = new OpenLayers.Map("map", options);
var abs_miny = this.image_points.miny;
try {
if(abs_miny < 0) {
//alert("abs_miny < 0");
abs_miny = abs_miny * -1;
}
} catch(e) {
alert(e);
}
var image = null;
try {
image =
new OpenLayers.Layer.WMS(
"UCB:images - Tiled",
'http://gis.lib.berkeley.edu:8080/geoserver/wms',
{CQL_FILTER:
"PATH='furtwangler/17076013_03_028a.tif'",
LAYERS: 'UCB:images',
STYLES: "",
format: "image/jpeg",
palette: "safe",
tiled: true,
tilesOrigin : map.maxExtent.left + ", " +
map.maxExtent.bottom},
// version: "1.1.1",
// bbox: this.image_points.minx + ", " +
this.image_points.miny + ", " + this.image_points.maxx + ", " +
this.image_points.maxy,
// width: this.image_points.maxx,
// height: abs_miny,
// srs: "EPSG:404000"},
{buffer: 0,
displayOutsideMaxExtent: true,
isBaseLayer: true } );
} catch(e) {
alert(e);
}
try {
var succ = map.addLayer(image);
map.zoomToMaxExtent({ restricted: false });
jQuery("collection_url").attr("href", '
http://www.lib.berkeley.edu/EART/mapviewer/collections/histoposf');
jQuery("collection_url").text('
http://www.lib.berkeley.edu/EART/mapviewer/collections/histoposf');
// map.render("map");
} catch(e) {
alert(e);
}
},
UGOLinit: function(/* loc, baseURL, layers, CQL, coda,
collectionURL */) {
:
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;
// make OL compute scale according to WMS spec
OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;
var that = this;
/* Ajax call to gss for image size */
jQuery.ajax({
url: '
http://linuxdev.lib.berkeley.edu:8080/newOGP/gss?file_path=furtwangler/17076013_03_028a.tif
',
data: null,
context: that,
success: that.success,
datatype: "json"}
);
}
}
jQuery(function() {
org.unGeoreferencedHelper.UGOLinit();
});
</script>
<script type="text/javascript">
function shutdown() {
}
</head>
<body>
<table>
<tr><td><div id="map"></div></td></tr>
<tr>
<td>You are previewing an ungeoreferenced image, which
cannot be displayed on the map.<br />
Move the image into the center of the window before
zooming.
</td>
</tr>
<tr>
<td>To see this image in its collection, see
<a id="collection_url" href=""></a>
</td>
</tr>
</table>
<button onClick="shutdown();">Shutdown</button>
</body>
</html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130802/cb888169/attachment.html>
More information about the Users
mailing list