Skip to main content

Problem with setCenter in OpenLayersOpenLayers2

I'm working with MapServer/PostgisPostGIS using OpenLayers to display map. I'm trying setCenter mapsetCenter map but it is not working!

My code:

var bounds = new OpenLayers.Bounds(107.567139, 12.326586, 108.258591,
        12.890796);
var options = {
    controls : [],
    maxExtent : bounds,
    maxResolution : 0.0010217594533836,
    projection : "EPSG:4326",
    units : 'degrees',
    allOverlays : true
};

map = new OpenLayers.Map('map', options);
.....
//Declare some layers wms
.....
map.addLayer(wms_RanhGioi);
map.addLayer(wms_GiaoThong);
map.addLayer(wms_ATM);
map.addLayer(wms_Cafe);
map.addLayer(wms_KhachSan);
map.addLayer(wms_NhaHang);
map.addLayer(wms_TramXang);

map.addControl(new OpenLayers.Control.LayerSwitcher({
    'ascending' : false
}));
map.addControl(new OpenLayers.Control.PanZoomBar({
    position : new OpenLayers.Pixel(2, 15)
}));
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new OpenLayers.Control.MousePosition({
    element : $('location')
}));
map.zoomToExtent(bounds);
map.setCenter(new OpenLayers.LonLat(12.67812, 108.04401), 5);

Somebody canCan somebody help me?

Problem with setCenter in OpenLayers

I'm working with MapServer/Postgis using OpenLayers to display map. I'm trying setCenter map but it is not working!

My code:

var bounds = new OpenLayers.Bounds(107.567139, 12.326586, 108.258591,
        12.890796);
var options = {
    controls : [],
    maxExtent : bounds,
    maxResolution : 0.0010217594533836,
    projection : "EPSG:4326",
    units : 'degrees',
    allOverlays : true
};

map = new OpenLayers.Map('map', options);
.....
//Declare some layers wms
.....
map.addLayer(wms_RanhGioi);
map.addLayer(wms_GiaoThong);
map.addLayer(wms_ATM);
map.addLayer(wms_Cafe);
map.addLayer(wms_KhachSan);
map.addLayer(wms_NhaHang);
map.addLayer(wms_TramXang);

map.addControl(new OpenLayers.Control.LayerSwitcher({
    'ascending' : false
}));
map.addControl(new OpenLayers.Control.PanZoomBar({
    position : new OpenLayers.Pixel(2, 15)
}));
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new OpenLayers.Control.MousePosition({
    element : $('location')
}));
map.zoomToExtent(bounds);
map.setCenter(new OpenLayers.LonLat(12.67812, 108.04401), 5);

Somebody can help me?

Problem with setCenter in OpenLayers2

I'm working with MapServer/PostGIS using OpenLayers to display map. I'm trying setCenter map but it is not working!

My code:

var bounds = new OpenLayers.Bounds(107.567139, 12.326586, 108.258591,
        12.890796);
var options = {
    controls : [],
    maxExtent : bounds,
    maxResolution : 0.0010217594533836,
    projection : "EPSG:4326",
    units : 'degrees',
    allOverlays : true
};

map = new OpenLayers.Map('map', options);
.....
//Declare some layers wms
.....
map.addLayer(wms_RanhGioi);
map.addLayer(wms_GiaoThong);
map.addLayer(wms_ATM);
map.addLayer(wms_Cafe);
map.addLayer(wms_KhachSan);
map.addLayer(wms_NhaHang);
map.addLayer(wms_TramXang);

map.addControl(new OpenLayers.Control.LayerSwitcher({
    'ascending' : false
}));
map.addControl(new OpenLayers.Control.PanZoomBar({
    position : new OpenLayers.Pixel(2, 15)
}));
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new OpenLayers.Control.MousePosition({
    element : $('location')
}));
map.zoomToExtent(bounds);
map.setCenter(new OpenLayers.LonLat(12.67812, 108.04401), 5);

Can somebody help me?

removed thanks
Source Link
nmtoken
  • 13.6k
  • 5
  • 38
  • 89

Problem with setCenter in openlayersOpenLayers

I'm working with MapServer/Postgis using OpenLayers to display map! I'm. I'm trying setCenter map but it is not working! My

My code:

var bounds = new OpenLayers.Bounds(107.567139, 12.326586, 108.258591,
        12.890796);
var options = {
    controls : [],
    maxExtent : bounds,
    maxResolution : 0.0010217594533836,
    projection : "EPSG:4326",
    units : 'degrees',
    allOverlays : true
};

map = new OpenLayers.Map('map', options);
.....
//Declare some layers wms
.....
map.addLayer(wms_RanhGioi);
map.addLayer(wms_GiaoThong);
map.addLayer(wms_ATM);
map.addLayer(wms_Cafe);
map.addLayer(wms_KhachSan);
map.addLayer(wms_NhaHang);
map.addLayer(wms_TramXang);

map.addControl(new OpenLayers.Control.LayerSwitcher({
    'ascending' : false
}));
map.addControl(new OpenLayers.Control.PanZoomBar({
    position : new OpenLayers.Pixel(2, 15)
}));
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new OpenLayers.Control.MousePosition({
    element : $('location')
}));
map.zoomToExtent(bounds);
map.setCenter(new OpenLayers.LonLat(12.67812, 108.04401), 5);

Somebody can help me! Thanks!!!?

Problem with setCenter in openlayers

I'm working with MapServer/Postgis using OpenLayers to display map! I'm trying setCenter map but it not working! My code:

var bounds = new OpenLayers.Bounds(107.567139, 12.326586, 108.258591,
        12.890796);
var options = {
    controls : [],
    maxExtent : bounds,
    maxResolution : 0.0010217594533836,
    projection : "EPSG:4326",
    units : 'degrees',
    allOverlays : true
};

map = new OpenLayers.Map('map', options);
.....
//Declare some layers wms
.....
map.addLayer(wms_RanhGioi);
map.addLayer(wms_GiaoThong);
map.addLayer(wms_ATM);
map.addLayer(wms_Cafe);
map.addLayer(wms_KhachSan);
map.addLayer(wms_NhaHang);
map.addLayer(wms_TramXang);

map.addControl(new OpenLayers.Control.LayerSwitcher({
    'ascending' : false
}));
map.addControl(new OpenLayers.Control.PanZoomBar({
    position : new OpenLayers.Pixel(2, 15)
}));
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new OpenLayers.Control.MousePosition({
    element : $('location')
}));
map.zoomToExtent(bounds);
map.setCenter(new OpenLayers.LonLat(12.67812, 108.04401), 5);

Somebody can help me! Thanks!!!

Problem with setCenter in OpenLayers

I'm working with MapServer/Postgis using OpenLayers to display map. I'm trying setCenter map but it is not working!

My code:

var bounds = new OpenLayers.Bounds(107.567139, 12.326586, 108.258591,
        12.890796);
var options = {
    controls : [],
    maxExtent : bounds,
    maxResolution : 0.0010217594533836,
    projection : "EPSG:4326",
    units : 'degrees',
    allOverlays : true
};

map = new OpenLayers.Map('map', options);
.....
//Declare some layers wms
.....
map.addLayer(wms_RanhGioi);
map.addLayer(wms_GiaoThong);
map.addLayer(wms_ATM);
map.addLayer(wms_Cafe);
map.addLayer(wms_KhachSan);
map.addLayer(wms_NhaHang);
map.addLayer(wms_TramXang);

map.addControl(new OpenLayers.Control.LayerSwitcher({
    'ascending' : false
}));
map.addControl(new OpenLayers.Control.PanZoomBar({
    position : new OpenLayers.Pixel(2, 15)
}));
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new OpenLayers.Control.MousePosition({
    element : $('location')
}));
map.zoomToExtent(bounds);
map.setCenter(new OpenLayers.LonLat(12.67812, 108.04401), 5);

Somebody can help me?

Source Link

Problem with setCenter in openlayers

I'm working with MapServer/Postgis using OpenLayers to display map! I'm trying setCenter map but it not working! My code:

var bounds = new OpenLayers.Bounds(107.567139, 12.326586, 108.258591,
        12.890796);
var options = {
    controls : [],
    maxExtent : bounds,
    maxResolution : 0.0010217594533836,
    projection : "EPSG:4326",
    units : 'degrees',
    allOverlays : true
};

map = new OpenLayers.Map('map', options);
.....
//Declare some layers wms
.....
map.addLayer(wms_RanhGioi);
map.addLayer(wms_GiaoThong);
map.addLayer(wms_ATM);
map.addLayer(wms_Cafe);
map.addLayer(wms_KhachSan);
map.addLayer(wms_NhaHang);
map.addLayer(wms_TramXang);

map.addControl(new OpenLayers.Control.LayerSwitcher({
    'ascending' : false
}));
map.addControl(new OpenLayers.Control.PanZoomBar({
    position : new OpenLayers.Pixel(2, 15)
}));
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new OpenLayers.Control.MousePosition({
    element : $('location')
}));
map.zoomToExtent(bounds);
map.setCenter(new OpenLayers.LonLat(12.67812, 108.04401), 5);

Somebody can help me! Thanks!!!