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

Vishal Mehta vishalm1975 at gmail.com
Wed Apr 13 20:31:39 EDT 2011


Hi Arnd,

The Google Maps base layer is in spherical mercator.
The kml is of course in EPSG:4326, but since i am defining its projection,
OL should still be able to overlay it, right?

FYI, I created the kml from a shapefile using ogr2ogr - it opens fine in
Google Earth.

So far i've been thinking its a proxy host problem.

The only other thing i can think of is from the Crowdmap mailing list:- on
Crowdmap, if there is no style and icon size attribute in the kml, then that
kml will not show at all. By adding these tags to 2 or 3 of the 472 points
in my kml, i was able to see it on Crowdmap.

The default ogr2ogr conversion from shp to kml does not populate the kml
with style and icon size tags.

Could this be the problem - does anybody have that experience with OL?
Vishal


On Wed, Apr 13, 2011 at 11:11 AM, Arnd Wippermann <arnd.wippermann at web.de>wrote:

>  Hi,
>
> if your page and kml comes from the same location like:
>
> http://yourserver/somepage.html
> http:*//yourserver/data/somevectors.kml*<http://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
>



-- 
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/60986d23/attachment-0001.html


More information about the Users mailing list