[OpenLayers-Users] Can Not Extract Attributes in KML File

reinaldo at geodesign.com.br reinaldo at geodesign.com.br
Fri Nov 9 07:53:08 PST 2012


Robertico,

I do not want the attributes to pop up as you click on the feature. I want
to render the label and in another situation I want to style polygons with
OpenLayers.Rule based on an attribute.

Reinaldo

------------------------------------

Reinaldo Escada Chohfi
Sócio Gerente
GeoDesign Internacional
www.geodesign.com.br (http://www.geodesign.com.br)
Tel./Fax: (12) 3153-5115
Inteligência e Tecnologia Espacial de Ponta
---- Original Message ----
From: robertico 
To: openlayers-users at lists.osgeo.org
Sent: Sex, Nov 9, 2012, 13:45 PM
Subject: Re: [OpenLayers-Users] Can Not Extract Attributes in KML File

Is there a function for a popup ?
	// Interaction; not needed for initial display.selectControl = new
OpenLayers.Control.SelectFeature(layer);map.addControl(selectControl);selectControl.activate();layer.events.on({'featureselected':
onFeatureSelect,'featureunselected': onFeatureUnselect});// Needed only for
interaction, not for the display.function onPopupClose(evt) {// 'this' is
the popup.var feature = this.feature;if (feature.layer) { // The feature is
not destroyedselectControl.unselect(feature);} else { // After "moveend" or
"refresh" events on POIs layer all  //     features have been destroyed by
the Strategy.BBOXthis.destroy();}}function onFeatureSelect(evt) {feature =
evt.feature;popup = new OpenLayers.Popup.FramedCloud("featurePopup",
feature.geometry.getBounds().getCenterLonLat(), new
OpenLayers.Size(100,100), //""+feature.attributes.title + "" +
feature.attributes.description, createPopupForm(),//replacement for
previous line and works better for kml file null, true,
onPopupClose);feature.popup = popup;popup.feature =
feature;map.addPopup(popup, true);}// cutom poup formfunction
createPopupForm() { var theHTML = ''; var layerVector   = map.layers[1];
var selectedFeature = layerVector.selectedFeatures[0]; var attributeName  =
selectedFeature.attributes['name'] ? selectedFeature.attributes['name'] :
"no name available"; theHTML += ''; theHTML += '' + attributeName + '' ;
for(var key in selectedFeature.attributes) {   if(key != "name" && key !=
"time" && key != "styleUrl") //theHTML += '' + key + ' :' +
selectedFeature.attributes[key] + ''; theHTML += '' +
selectedFeature.attributes[key] + ''; } theHTML += ''; return theHTML; }
function onFeatureUnselect(evt) {feature = evt.feature;if (feature.popup)
{popup.feature =
null;map.removePopup(feature.popup);feature.popup.destroy();feature.popup =
null;}}

------------------------------------
View this message in context: Re: Can Not Extract Attributes in KML File
(http://osgeo-org.1560.n6.nabble.com/Can-Not-Extract-Attributes-in-KML-File-tp5015176p5015198.html)
Sent from the OpenLayers Users mailing list archive
(http://osgeo-org.1560.n6.nabble.com/OpenLayers-Users-f3910695.html) at
Nabble.com.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20121109/61f530cd/attachment.html>


More information about the Users mailing list