It seems that the error actually comes from map.setCenter() and if a layer is added first all is well, while the addOptions() function seems to apply to layers rather than the map. I added that option to the map constructor and it made no difference. My problem now is just that I can get this to work but only after a layer has been added but ideally I need to know the origin before a layer is added. Maybe I can add a dummy layer? Apparently Geoserver now uses OpenLayers for it's demos and they use exactly what I'm trying to achieve so I'm going to have a look into how they've done it...
<br><br>thanks all.<br><br><div><span class="gmail_quote">On 5/31/07, <b class="gmail_sendername">Stephen Woodbridge</b> <<a href="mailto:woodbri@swoodbridge.com">woodbri@swoodbridge.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Tom wrote:<br>> Hi all,<br>><br>> I'm currently trying to get the co-ordinates of the origin of the map in<br>> order to utilise the geoserver meta tiler extension to WMS see:<br>> <a href="http://docs.codehaus.org/display/GEOSDOC/WMS+vendor+parameters">
http://docs.codehaus.org/display/GEOSDOC/WMS+vendor+parameters</a> These<br>> co-ordinates must be included in the WMS URL so I'm doing the following:<br><br>I ran into this error the other night and found that I had forgotten to set:
<br><br>map.addOptions({isBaseLayer: true});<br><br>which seemed to solve the problem.<br><br>-Steve W.<br><br>> ...<br>> var map;<br>> function init()<br>> {<br>> var options =<br>> {resolutions:[72,36,18,
9.6,4.8,2.4,1.2,0.6,0.3,0.15,0.125],maxExtent:new<br>> OpenLayers.Bounds(0,0,2000000,2000000),maxResolution:'auto',units:'meters',projection:'EPSG:27700',controls:[]};<br>> map = new OpenLayers.Map
( $('map'), options );<br>> map.setCenter(new OpenLayers.LonLat(543443,255213), 7);<br>> var olextent = map.getExtent();<br>> var origincoords=toString(olextent.bottom) + ',' + toString(olextent.left
);<br>> ...<br>><br>> and I'm getting the following error:<br>><br>> maxExtent has no properties<br>> isValidLonLat(lon=543443,lat=255213 lon=543443 lat=255213 CLASS_NAME=<br>> OpenLayers.LonLat)Map.js (line 933)
<br>> setCenter( lon=543443,lat=255213 lon=543443 lat=255213<br>> CLASS_NAME=OpenLayers.LonLat , 7, undefined, undefined)Map.js (line 804)<br>> init() classexample.php (line 11)<br>> onload(load ) classexample.php
(line 1)<br>> valid = maxExtent.containsLonLat(lonlat);<br>><br>> Any ideas?<br>><br>> cheers,<br>><br>> Tom<br>><br>><br>><br>><br>> ------------------------------------------------------------------------
<br>><br>> _______________________________________________<br>> Users mailing list<br>> <a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br>> <a href="http://openlayers.org/mailman/listinfo/users">
http://openlayers.org/mailman/listinfo/users</a><br><br></blockquote></div><br>