[OpenLayers-Users] setCenter problem

Barry Hunter barry at barryhunter.co.uk
Thu Aug 2 11:33:39 EDT 2007


It might be a typo:

map1 = new OpenLayers.Map('map', options);

which you later refer to as map.

(but not sure how it would work in the init function :(
(the map in quotes is the name of the html div, I guess it could work to an
extent like that, if OL makes the JS object actully the same as the html
object)

On 8/2/07, Tyler Durden <tylersticky at gmail.com> wrote:
>
> Hi,
> I have list of links:
> Example:
> <a href="#" onclick="map.setCenter(new OpenLayers.LonLat(16.0, 41.0),
> 8);">show</a>
>
> But nothing happens.
>
> setCenter() only applies on init()?
>
> var lon = -8.61057;
> var lat = 41.14452;
> var zoom = 8;
> var bounds = new OpenLayers.Bounds(-11.535, 36.095, -4.535, 43.095);
> var map, layer_continente;
>
> function initMap() {
>     var options = { maxResolution : 0.015693359375,
>                     numZoomLevels : 12,
>                     maxExtent     : bounds,
>                     projection    : "EPSG:4326"}
>
>     map1 = new OpenLayers.Map('map', options);
>     layer_continente = new OpenLayers.Layer.WMS("continente",
> "http://localhost:8080/", {"layers":"continente",
> "format":"image/png"})
>     map.addLayer(layer_continente);
>
>     map.addControl(new OpenLayers.Control.PanZoom());
>     map.addControl(new OpenLayers.Control.MousePosition());
>     map.addControl(new OpenLayers.Control.MouseDefaults());
>     map.addControl(new OpenLayers.Control.Permalink());
>
>     map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
> }
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



-- 
Barry

- www.nearby.org.uk - www.geograph.org.uk -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20070802/d279638b/attachment.html


More information about the Users mailing list