Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to load a KML file into an Openlayers map. It seems to successfully run but I am not seeing anything show up on the map.

Vectors should show up in an area of New Mexico if it's working correctly.

Here is my code (here is a link to the KML file )

var map;

var baseMaps = [];
var sensors = [];

//create map and center over location
var init = function () {
    // create map

    map = new OpenLayers.Map({
        div: "map",
        theme: null,
        projection:new OpenLayers.Projection("EPSG: 4326"),
        controls: [
            new OpenLayers.Control.Attribution(),
            new OpenLayers.Control.TouchNavigation({
                dragPanOptions: {
                    enableKinetic: true
            new OpenLayers.Control.Zoom()
        layers: [
            new OpenLayers.Layer.OSM()

    map.setCenter(new OpenLayers.LonLat(-106.7653, 32.3197).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()),9);

//show kmlFile
var showSensor = function(sensorVO)
    if(sensorVO.selected == true)
        var kmllayer = new OpenLayers.Layer.Vector("KML", {
            strategies: [new OpenLayers.Strategy.Fixed()],
            protocol: new OpenLayers.Protocol.HTTP({
                url: sensorVO.url,
                format: new OpenLayers.Format.KML({
                    extractStyles: true, 
                    extractAttributes: true,
                    maxDepth: 2

        var select = new OpenLayers.Control.SelectFeature(kmllayer);

        map.setCenter(new OpenLayers.LonLat(-106.639261,32.649908).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()),10);

        var obj = {"vo":sensorVO, "kmlLayer":kmllayer};


        for (var i = 0; i < sensors.length; i++) 
            var vo = sensors[i].vo;
            if( ==
                sensors.splice(i, 1);





    var obj = {"id":1, "selected":true, "url":"kml-files/1858-Vegitation-Map.kml"};

}, 1000);
share|improve this question
105.9372, 35.6869 is incorrect Santa Fe is 35.6869, -105.9372 – Mapperz Jan 23 '13 at 19:27
A bad practice: you add a new layer every second (e.g your timeout function) You'd better add the layer and only refresh it regularly >>… – ThomasG77 May 25 '13 at 0:08

I couldn't access your KML file to see if it's storing points of lines, but that would be a starting check. KML can support the following geometries: Point, LineString, LinearRing, Polygon and MultiGeometry. Since a KML file is ASCII rather than binary you can open it in a text editor to make sure the coordinates are defined to the correct geometery. The coordinates should be clearly specified. Does the KML say that they are or ?

share|improve this answer
I tried zipping the file and sharing. see if that helps – mattwallace Jan 23 '13 at 21:46
I think you probably have your kml file uploaded correctly, I just can't retrieve due to a firewall from my end – user12711 Jan 24 '13 at 15:50

Your Answer


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.