1

I have KML files (EPSG:4326) and a background map I made using EPSG:2039 projection (mandatory).

When I try reprojecting the KMLs to show in EPSG:2039 I don't succeed and still they don't appear on the map. Only when manually projecting everything to EPSG:4326 its working (But I need to be in EPSG:2039 for the client)

 init: function () {

    var transperantLayers = ["kml1", "kml2", "kml3"];

    var P2039 = new OpenLayers.Projection("EPSG:2039");
    var P4326 = new OpenLayers.Projection("EPSG:4326");

    var activeProjection = P2039;

    OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;

    var options = {
        maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34),
        projection: activeProjection,
        displayProjection: P4326
    };      

    var map = new OpenLayers.Map("map", options);

    var base = new OpenLayers.Layer.MapInfoRESTHandler("Background", "MapTileServer",
                            { mapname: "Background", output: 'image/png', tileType: 'MBR', transparent: false },
                            { isBaseLayer: true, buffer: 1, transitionEffect: 'resize' });

    map.addLayer(base);

    for (var i = 0; i < transperantLayers.length; i++) {
        var layer = new OpenLayers.Layer.Vector(transperantLayers[i], {
            projection: map.projection,
            strategies: [new OpenLayers.Strategy.Fixed()],
            protocol: new OpenLayers.Protocol.HTTP({
                url: "KMLs/" + transperantLayers[i] + ".KML",
                format: new OpenLayers.Format.KML({
                    extractStyles: true,
                    extractAttributes: true
                })
            })
        });
        layer.setOpacity(0.5);
        map.addLayer(layer);
    }

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

    map.setCenter(new OpenLayers.LonLat(220000, 632000), 9);        

}

I've also tried instead of :

projection: map.projection

doing :

projection: map.displayProjection

but still no luck... not seeing the KMLs.

Help will be appreciated.

1

Problem solved: I just noticed there wasnt epsg2039.js file in the def directory. I've added it and now it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.