Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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