Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I looked on similar questions but in vain. The map is working fine but has a center of (0,0) as returned in the Firebug console not (-8, 32) that I want. I did the projection transformation.. Here is my code :

enter image description here

share|improve this question
add comment

2 Answers

i am curious about that have you tried setMapObjectCenter method for solving this problem.

setMapObjectCenter

setMapObjectCenter: function (center,
zoom    )
Set the mapObject to the specified center and zoom

Parameters
center  {Object} MapObject LonLat format
zoom    {int} MapObject zoom format

i hope it helps you...

share|improve this answer
    
I've tried that as well when I looked on the Openlayers Documentation for Google v3 layer :( –  YossBen Apr 29 '12 at 15:13
    
But it seem I didn't manage to use that function properly. Would you plz write how I can use it? –  YossBen Apr 29 '12 at 15:26
    
I've tried this------map.layers[0].setMapObjectCenter = function(center, zoom){center=lonlat; zoom=4;}; –  YossBen Apr 29 '12 at 16:10
    
it is already a function. Your method is defining a new function in vain for solving the problem. map.layers[0].setMapObjectCenter(lonlat, zoom) should work for you. –  Aragon Apr 29 '12 at 17:01
    
I've been using all this along with GeoExt, as soon as I removed all the GeoExt panels, tree, etc, it worked! –  YossBen Apr 30 '12 at 18:00
add comment
up vote 0 down vote accepted

Actually, I had to give a look on GeoExt Documentation as well especially the class GeoExt.mapPanel link here. The center of the map and the initial zoom must be specified in there and it worked finally:

    (...)map.addLayers([Gmap, institutions, pays]); 
    var point = new OpenLayers.LonLat(-6, 33); 
    point.transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
    var mapPanel = new GeoExt.MapPanel({
        region: 'center',
        height: 550,
        width: 1000,
        map: map,
        zoom: 4,
        center: point,
        title: 'Carte'
    });
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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