// general constant
var SHADOW_Z_INDEX = 10;
var MARKER_Z_INDEX = 11;


// dati mappa 
var map = Object;
var goost = Object;
var ol_wms = Object;
var layerMapnik = Object;


var extMap = new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34);

// posizioni w l e d in geomerchator
var coord = { uff:{lon:1199139.3222566557,lat: 5447387.532241559,extGrap:"/layout/img/ol/marker_gis3w.png",name:"Walter Lorenzetti"}};

function bldStyleMap(who){
 return new OpenLayers.StyleMap({
      // Set the external graphic and background graphic images.
      externalGraphic: coord[who].extGrap,
      backgroundGraphic: "/layout/img/ol/marker_gis3w_bk.png",

      graphicYOffset: -55,
      graphicWidth: 60,
      graphicHeight: 55,
      // Makes sure the background graphic is placed correctly relative
      // to the external graphic.
      backgroundXOffset: 0,
      backgroundYOffset: -55,
      
      // Set the z-indexes of both graphics to make sure the background
      // graphics stay in the background (shadows on top of markers looks
      // odd; let's not do that).
      graphicZIndex: MARKER_Z_INDEX,
      backgroundGraphicZIndex: SHADOW_Z_INDEX,
      
      pointRadius: 10
  });
}
        

function init_map(){
var wh = 'uff';
// si avvia un solo oggetto strato per tutte e tre
ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS","http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
goost = new OpenLayers.Layer.Google("Google Streets",{ sphericalMercator: true });
layerMapnik = new OpenLayers.Layer.OSM.Mapnik("OpenStreetMap");
  
  map = new OpenLayers.Map('map',{
                                 maxExtent: extMap,
                                  numZoomLevels: 19,
                                  maxResolution: 156543.0399,
                                  units: 'm',
                                  projection: new OpenLayers.Projection("EPSG:900913")
//                                   displayProjection: new OpenLayers.Projection("EPSG:4326")

                                  });
  // costruzione del vettore per la posizione
  posi = new OpenLayers.Layer.Vector(
                coord[wh].name,
                {
                    styleMap: bldStyleMap(wh),
                    isBaseLayer: false,
                    rendererOptions: {yOrdering: true}
                }
            );
  var features = [];
  features.push(
      new OpenLayers.Feature.Vector(
          new OpenLayers.Geometry.Point(coord[wh].lon, coord[wh].lat)
      )
  );
  
  posi.addFeatures(features);
  
  map.addLayers([layerMapnik,goost,ol_wms,posi]);
  map.addControl(new OpenLayers.Control.LayerSwitcher()); 
//   map.addControl(new OpenLayers.Control.MousePosition());
  map.setCenter(new OpenLayers.LonLat(coord[wh].lon, coord[wh].lat),10);


}