var map; //complex object of type OpenLayers.Map

// Initialise the 'map' object
function render_fincamap(container, finca) {
    var dproj = new OpenLayers.Projection("EPSG:4326");
    var mproj = new OpenLayers.Projection("EPSG:900913");
    var layerFincas;
    // Define the map layer
    var layerRoads = new OpenLayers.Layer.OSM("Straßenkarte",
      ["/tiles/${z}/${x}/${y}.png"], {
        maxResolution: 305.7481,
        numZoomLevels: 3,
        attribution: "Kartendaten von <a href='http://openstreetmap.org/'>OpenStreetMap</a> und Mitwirkende, CC-By-SA"
    });

    layerFincas = new OpenLayers.Layer.GML("Fincas", "/cms/fincapos/show/" + finca, {
        format: OpenLayers.Format.GeoJSON,
        projection: mproj,
        style: {
                externalGraphic: "/cms/images/house.png",
                fillOpacity: 1,
                hoverFillOpacity: 1,
                graphicWidth: 13,
                graphicHeight: 13,
                graphicXOffset: -7,
                graphicYOffset: -7 
            }
    });

    map = new OpenLayers.Map (container, {
        controls:[
            new OpenLayers.Control.PanZoom(),
            new OpenLayers.Control.ScaleLine(),
            new OpenLayers.Control.Attribution(),
            new OpenLayers.Control.Navigation()
        ],
        maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
        restrictedExtent: (new OpenLayers.Bounds(2.25, 39.25, 3.5, 40)).transform(dproj, mproj),
        maxResolution: 305.7481,
        numZoomLevels: 3,
        units: 'm',
        projection: mproj,
        displayProjection: dproj
    });
    map.addLayer(layerRoads);
    map.addLayer(layerFincas);
    map.zoomToMaxExtent();
}
