1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
var map;
var geographic = new OpenLayers.Projection("EPSG:4326");
var mercator = new OpenLayers.Projection("EPSG:900913");
function init(){
//***************creation de la carte**********************
var world = new OpenLayers.Bounds(-180, -89, 180, 89).transform(geographic, mercator);
var center = new OpenLayers.LonLat(-7.56,33.59).transform(geographic, mercator);
var options = {
projection: mercator,
displayProjection: new OpenLayers.Projection("EPSG:4326"),
units: "m",
maxExtent: world
};
map = new OpenLayers.Map("map", options);
//*****************fond google*************
var fondgoogle = new OpenLayers.Layer.Google(
"Google Streets", // the default
{
numZoomLevels : 27
})
map.addLayers([fondgoogle]);
//******** mon layer wms ************************
layer_wms = new OpenLayers.Layer.WMS(
"layer_wms",
"http://localhost:8080/geoserver/namespace/wms"
,{layers: "namespace:layer_wms", 'format':'image/png', 'transparent':'true'}
,{'opacity': 1.0, 'isBaseLayer': false, 'visibility': true, 'displayInLayerSwitcher': true}
);
map.addLayers([layer_wms]);
info = new OpenLayers.Control.WMSGetFeatureInfo({
url: 'http://localhost:8080/geoserver/namespace/wms',
title: 'Identify features by clicking',
queryVisible: true,
eventListeners: {
getfeatureinfo: function(event) {
map.addPopup(new OpenLayers.Popup.FramedCloud(
"chicken",
map.getLonLatFromPixel(event.xy),
null,
event.text,
null,
true
));
}
}
});
map.addControl(info);
info.activate(); |
Partager