KML Layer help.

2043
2
06-23-2012 11:05 PM
Zhong_DaSeah
New Contributor
Hi,
    I am sort of new to this. And I am having a problem 'importing' kml files into my base map. I am quite sure that my links for my kml files is public accessible, and have no idea what is wrong. I have followed the examples provided by the Arcgis javascript API with no avail. I am hoping to get some help here.

The following is the snippet of my javascript codes:

        dojo.require("esri.map");
        dojo.require("esri.layers.KMLLayer");
 
        var myMap, myTiledMapServiceLayer;
        function init() {
            myMap = new esri.Map("mapDiv");
            myTiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://www.onemap.sg/ArcGIS/rest/services/basemap/MapServer");
            myMap.addLayer(myTiledMapServiceLayer);
            var kmlUrl = 'http://dl.dropbox.com/s/h5hs78sf6tgoqol/polyclinics.kml';
            var kml = new esri.layers.KMLLayer(kmlUrl);
            myMap.addLayer(kml);


            dojo.connect(kml, 'onLoad', function () {
                dojo.style(dojo.byId('loading'), 'display', 'none');
            });

            dojo.connect(myMap, 'onLoad', function() {
            //resize the map when the browser resizes
                 dojo.connect(dijit.byId('mapDiv'), 'resize', map,map.resize);
            });
        }
        dojo.ready(init);

I have tried importing the hardcopy of the kml file to the onemap.sg server (they have a function to allow the overlaying of personal kml files) and it works perfectly.
I am also not sure if I need to set the extent of the map in order to get it to work. But as for now, the onemap's map is showing on my browser, but not the overlay.
Any help would be appreciated.
0 Kudos
2 Replies
RonaldHenderson
New Contributor
I tried opening your kml file and got a 404 error, so I don't think it is publicly available.
I have built a few maps using kml files and I test the file by putting the url in a browser and see if it opens.
RJ
0 Kudos
JeffPace
MVP Alum
kml must be public.
0 Kudos