Hi,

I am fairly new to OpenLayers but not GIS or ASP.Net and I'm trying to get 
OpenLayers working on an ASP.Net site. I've started by copying the sample OSM + 
Gooogle Maps + KML Reprojection and it seems that the Open Street Maps and 
Google layers are working fine. However the KML is not being projected onto the 
same coordinate system as the tiles (the KML is is WGS84/EPSG:4326) and all the 
points appear to be being rendered somewhere just off the west coast of Africa 
(where I guess 0,0 is for the tile coordinate system EPSG:900913) but clearly 
at different points if you zoom in enough.

It all seems to work on the openlayers sample site and I'm sure that I've 
copied the code correctly (I've pasted it below, I removed the google stuff 
just to make this as simple as possible). Is there perhaps something tricky to 
setting up the reprojection?

I've worked with a local copy of OpenLayers.js and the separate file version 
and the hosted version, they all give the same result. 

var map, select;

function init(){

    window.onresize = onWindowResize;
    sizeMap();
    
    var options = {
        projection: new OpenLayers.Projection("EPSG:900913"),
        displayProjection: new OpenLayers.Projection("EPSG:4326"),
        units: "m",
        maxResolution: 156543.0339,
        maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
                                         20037508.34, 20037508.34)
    };
    map = new OpenLayers.Map('map', options);
    
    var mapnik = new OpenLayers.Layer.TMS(
        "OpenStreetMap (Mapnik)",
        "http://tile.openstreetmap.org/";,
        {
            type: 'png', getURL: osm_getTileURL,
            displayOutsideMaxExtent: true,
            attribution: ' OpenStreetMap '
        }
    );

    var sundials = new OpenLayers.Layer.Vector("KML", {
        projection: map.displayProjection,
        strategies: [new OpenLayers.Strategy.Fixed()],
        protocol: new OpenLayers.Protocol.HTTP({
            url: "kml/sundials.kml",
            format: new OpenLayers.Format.KML({
                extractStyles: true,
                extractAttributes: true
            })
        })
    });
    
    map.addLayers([mapnik, sundials]);

    select = new OpenLayers.Control.SelectFeature(sundials);
    
    sundials.events.on({
        "featureselected": onFeatureSelect,
        "featureunselected": onFeatureUnselect
    });

    map.addControl(select);
    select.activate();   

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

    map.zoomToExtent(
        new OpenLayers.Bounds(
            16, 33, 47, 54
        ).transform(map.displayProjection, map.projection)
    );

-- 
View this message in context: 
http://n2.nabble.com/Beginner%3A-mapping-different-coordinate-sources-systems-together-tp2604043p2604043.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.

_______________________________________________
Dev mailing list
Dev@openlayers.org
http://openlayers.org/mailman/listinfo/dev

Reply via email to