my layers are in wgs84 and I need to zoomToExtend to specific Bound's but it seems I can not make it.... The code seems ok but nothing happens.

map = new OpenLayers.Map({
            div: "map",
            units: "m", 
            projection: googleMercator,
            displayProjection: wgs84
        var minLat = 38.79;
        var minLng = 24.09;
        var maxLat = 42.08;
        var maxLng = 25.61;

        map.zoomToExtent(new OpenLayers.Bounds(minLng,minLat,maxLng,maxLat).transform(wgs84, googleMercator));

Solved my issue by the following code:

map.setCenter(new OpenLayers.LonLat(28.1231635,40.357895).transform(wgs84,googleMercator), 5);

Since I gave the coordinates to wgs84, i needed to transform them to googleMercator.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.