Xml gml

From DreamsteepWiki

Jump to: navigation, search

UNTESTED

    <script type="text/javascript">
    <!--

    function init()
    {

        var map = null;
        var lat = null;
        var lon = null;
        var zoom = null;

        OpenLayers.Layer.Google.prototype.addContainerPxFunction=function() {
            if (typeof GMap2 != "undefined" && !GMap2.prototype.fromLatLngToContainerPixel) {

                GMap2.prototype.fromLatLngToContainerPixel = function(gLatLng) {

                    // first we translate into "DivPixel"
                    var gPoint = this.fromLatLngToDivPixel(gLatLng);

                    // locate the sliding "Div" div
                    var div = this.getContainer().firstChild.firstChild;

                    // adjust by the offset of "Div" and voila!
                    gPoint.x += div.offsetLeft;
                    gPoint.y += div.offsetTop;

                    return gPoint;
                };
            }
        };

        // Create map
        map = new OpenLayers.Map( 'map', {controls: [], tileSize: new OpenLayers.Size(256,256), numZoomLevels: 10, controls: [new OpenLayers.Control.MouseDefaults()] } );

        // Add base layers
        map.addLayer(new OpenLayers.Layer.Google("Google Physical", {type: G_PHYSICAL_MAP, "sphericalMercator": true}));
        //map.addLayer(new OpenLayers.Layer.Google("Google Streets", {"sphericalMercator": true}));
        //map.addLayer(new OpenLayers.Layer.Google("Google Satelite", {type: G_SATELLITE_MAP, "sphericalMercator": true}));

        // Add image base layer
        map.addLayer(new OpenLayers.Layer.Image("Image layer","txt/111.png",new OpenLayers.Bounds(-180, -88.759, 180, 88.759),new OpenLayers.Size(580, 289)));

        // Add GML or XML POLYGON Layer
        map.addLayer(new OpenLayers.Layer.GML("GML", "gml/polygon.xml"));

        // Add popup layers
        map.addLayer(new OpenLayers.Layer.Text("points", {location: "txt/points.txt"} ));

        map.addControl(new OpenLayers.Control.PanZoomBar());
        map.addControl(new OpenLayers.Control.LayerSwitcher());

        // Center map
        lon = -78.676223;
        lat = 35.773519;
        zoom = 3;
        map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
    }

    // -->

    </script>
Personal tools