You are not logged in.

Announcement

*** NOTICE: forum.openstreetmap.org is being retired. Please request a category for your community in the new ones as soon as possible using this process, which will allow you to propose your community moderators.
Please create new topics on the new site at community.openstreetmap.org. We expect the migration of data will take a few weeks, you can follow its progress here.***

#1 2013-05-02 16:56:19

Lamce
Member
Registered: 2013-04-04
Posts: 8

SelectFeature highlighted nicht

Guten Tag,

Ich habe das Problem, dass das SelectFeature control das slectierte feature nicht highlighted.

Anfangs hatte ich noch ein zweites SelectFeature aktiv welches multiple selects realiseren sollte. Dieses hat auch funktioniert inkl highlight.
Als ich das multi-select entfernte, funktioniere das SelectFeature inkl Highlight. Aber auch nur well in der Funktion eine undefined-exception geworfen wurde. Ich verstehe nicht wie das im zusammenhang mit dem highlight liegt..

var styleMap = new OpenLayers.StyleMap({
	    "default": new OpenLayers.Style({
	        label: "${label}",
	        fill: true,
	        fillColor: '#FF0000',
	        fillOpacity: 0.5,
	        strokeWidth: 4,
	        strokeColor: 'white',
	        labelXOffset: '${getLableOffsetX}',
	        labelYOffset: '${getLableOffsetY}',
	        labelAlign: 'cm'
	    }, {
	        context: {
	        	getLableOffsetX: function (f){
	        		xy=labelDeltaPixels(f);
	            	return xy.x/2;
	            	},
	            getLableOffsetY: function (f){
	            	xy=labelDeltaPixels(f);
	            	java.log(xy.x+" "+xy.y);
	            	return xy.y/2;
	            	},
	            label: function (feature) {
	            	var arr = feature.attributes.ExtendedData.split(',');
            		var type = arr[0];
            		if(type=="REL"){	            	
	                	return feature.attributes.name;
            		}else{
            			return "";
            		}
	            }
	            
	        }
	    }),
        "select": {

            pointRadius: 20,
            fillColor: "#57FFD8",
            fillOpacity: 0.8,
            strokeColor: "#0000a1",
            strokeWidth: 4,
            strokeOpacity: 0.8
        }
	});
	
	kml = new OpenLayers.Layer.Vector("KML", {styleMap : styleMap});
mouseselectfeature = new OpenLayers.Control.SelectFeature(kml, {
		 clickout: false, toggle: false,
         multiple: false, hover: false,
			onSelect: onFeatureSelect
		});

	    map.addControl(mouseselectfeature);
	    mouseselectfeature.activate();
function onFeatureSelect(feature) {
	//java.log("onFeatureSelect");
	if(feature.attributes.ExtendedData){
		var arr = feature.attributes.ExtendedData.split(',');
		var type = arr[0];
		var id = arr[1];
		java.selectObject(type,id);
	}
}

Muss die aufgerufene Funktion einen Rückgabewert geben um den Style zu wählen?

Ich habe so einige Controls und Layer Events und Frage mich ob diese im zusammenhang darin stehen, dass das Highlight nicht funktioniert? Als ich zb das Multiselect hinzugefügt habe funktionierte das Highlight beim Select überhaupt nicht.

Wie ist es möglich für einen einzelnen Feature zwischen styles in der Stylemap zu wechseln? Dann könnte man das highlight manuell Programmieren. Dies brauche ich so wieso da das Javascript in einer Java Applikation läuft und ich ggf. von Java aus highlighten muss.

mfg
Lamce

Offline

#2 2013-05-05 17:59:13

Lamce
Member
Registered: 2013-04-04
Posts: 8

Re: SelectFeature highlighted nicht

Noch eine weitere Saache..

Die Position des Labels pro Linie wird ja errechnet. Das Problem ist wenn man zoomt, werden die Posititionen nicht neu errechnet und die Labels stehen dann irgendwo im Raum rum.
Wie erzwingt man, dass die Position der Labels neu berechnet werden?

Offline

Board footer

Powered by FluxBB