[OpenLayers-Users] Access to KML attributes

cbaldinu cbaldinu at gmail.com
Tue Sep 25 05:48:30 PDT 2012


Ok, i understood.

I post my code so, i hope, you can give me help just to put all together 


Here is my js code: 


var sundials = new OpenLayers.Layer.Vector("KML", {
                projection: map.displayProjection,
                strategies: [new OpenLayers.Strategy.Fixed()],
                protocol: new OpenLayers.Protocol.HTTP({
                    url: "custom_kml.kml",
                    format: new OpenLayers.Format.KML({
                        extractStyles: true,
                        extractAttributes: true
                    })
                })
            });


controls = {

                    drag: new OpenLayers.Control.DragFeature(sundials,
			{
	onComplete : getLatLon
			})
                };
				
				for(var key in controls) {
                    map.addControl(controls[key]);
                }


function getLatLon(event){
				
				var coord = this.feature.geometry.transform(
							new OpenLayers.Projection("EPSG:900913"),
							new OpenLayers.Projection("EPSG:4326")
							);
				alert('you clicked on '+coord.x+' N and '+coord.y+' E');
				
				
		}


What i want to do, after i drag a point, is, instead of printing an alert (
in the code is  alert('you clicked on '+coord.x+' N and '+coord.y+' E');), i
would like to print my id, just to use it with $.post() function on jquery
and make an update script on my DB.

In addition, how could i add a custom id on the kml so i can call that on a
jquery call?

Thanks,

Cristian Baldinu



--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Access-to-KML-attributes-tp5004222p5004257.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list