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

Arnd Wippermann arnd.wippermann at web.de
Wed Apr 13 14:11:25 EDT 2011


Hi,
 
if your page and kml comes from the same location like:
 
http://yourserver/somepage.html
http: <http://yourserver/data/somevectors.kml>
//yourserver/data/somevectors.kml
 
you don't need a proxy script to get the kml.
 
If it is so, then your script should work. The kml file (url:
"borewells.kml") is searched at the location of your page and there is no
need of a proxy script. There have to be an other reason, why you kml file
isn't displayed. Are you sure, that the coordinates in EPSG:4326 or that the
coordinates are lay in the viewport?
 
Arnd

  _____  

Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Vishal
Mehta
Gesendet: Mittwoch, 13. April 2011 00:17
An: users at openlayers.org
Betreff: [OpenLayers-Users] trouble adding local kml file to OL


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/20110413/1f6d66c5/attachment.html


More information about the Users mailing list