[OpenLayers-Users] trouble adding local kml file to OL

Vishal Mehta vishalm1975 at gmail.com
Tue Apr 12 18:17:18 EDT 2011


Hi all,

I;m having some trouble adding a kml file to openlayers. The script is at
bottom, and i've followed this thread without solving the problem:
http://osgeo-org.1803224.n2.nabble.com/adding-KML-file-td6003583.html

note that
(a) i have apache running (but no proxy host configured- i tried to do it
but it broke my web server, i'm not an expert at troubleshooting it.
(b) webserver is back on - i use it for an application with php and postgis
(which i actually want to link to an OL application)
(c) i am new to OL

1. with both the html and kml file on the webserver,
- i get only the google map displayed, no kml file displayed
- no error message
- no kml file displayed

2. with the html on local folder and kml file on webserver
- i get only the google map displayed
- error message Access to URL denied" code" 1012

3. with both html and kml files in local folder
   - same response as 1 above
   - although i dont know if i shoulde be using url to point to the file in
this case

The code is below. Any help appreciated!!
Also, do i absolutely need proxy hosting or is there some way i can use my
existing webserver and working postgis as is?
Thanks,
Vishal


<html>
<head>
  <title>OpenLayers Example</title>
    <script src="http://openlayers.org/api/OpenLayers.js"></script>
    <script src="http://maps.google.com/maps/api/js?sensor=false"></script>
    </head>
    <body>
      <div style="width:100%; height:100%" id="map"></div>
        var map = new OpenLayers.Map('map');

    var googlemap = new OpenLayers.Layer.Google('Google Layer');
    map.addLayer(googlemap);
    map.setCenter(
                new OpenLayers.LonLat(77.6, 13).transform(
                    new OpenLayers.Projection("EPSG:4326"),
                    map.getProjectionObject()
               ), 12);
    console.log(map.getProjection());
    var vector_layer = new OpenLayers.Layer.Vector('borewells',
        {
            projection: new OpenLayers.Projection('EPSG:4326'),
            protocol: new OpenLayers.Protocol.HTTP({
                url: "borewells.kml",
                format: new OpenLayers.Format.KML({
                    extractAttributes: true
                })
            }),
            strategies: [new OpenLayers.Strategy.Fixed()]
            }
        );
    //add it to the map
    map.addLayer(vector_layer);
    console.log('got here');
      </script>
</body>
</html>



-- 
Vishal K. Mehta, PhD
Scientist
Stockholm Environment Institute - US
133 D St Suite F
Davis CA 95616
www.sei-us.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110412/7b65f1fd/attachment-0001.html


More information about the Users mailing list