Add contextMenu I on the map of the highlightlayer, how to change the hightOverlayer is selected for feature color in the trigger ContextMenu menuItem click event
Map hightOverLayer Selected
Hi Li,
Thanks for your post and welcome to mapsuite world, attached is the sample code, would you please try it? If you have any more question, please feel free to let us know.
Hope it helps
Johnny
Post11240Sample.txt (1.45 KB)
Hi Johnny,
thinks for your replay ,If this.map.HighlightOverlay has a Feature so that it can be ,if there is more than one Feature will turn red all,I only want to change the selected Feature instead of all.
Hope you help
Hi Johnny,
thinks for your replay ,If this.map.HighlightOverlay has a Feature so that it can be ,if there is more than one Feature will turn red all,I only want to change the selected Feature instead of all.
Hope you help
Hi Johnny,
thinks for your replay ,If this.map.HighlightOverlay has a Feature so that it can be ,if there is more than one Feature will turn red all,I only want to change the selected Feature instead of all.
Hi Johnny,
thinks for your replay ,If this.map.HighlightOverlay has a Feature so that it can be ,if there is more than one Feature will turn red all,I only want to change the selected Feature instead of all.
Hope you help
Hi Li,
Attached is the new sample code, would you please try it? If you have any more question, please feel free to let us know.
Best Regards,
Johnny
Post11240.txt (2.19 KB)
dear
Map hightlightoverlayer feature color can be changed,but in the hightlightoverlayer contextMenuItem.click forms page will refresh, refresh time is in blank, waiting for will display 1 seconds later, how can not let the page refresh?
Hi Li,
Attached is the sample code, would you please try it?
Hope it helps
Johnny
001_Post11240Sample.txt (2.02 KB)
dear Johnny
var lastSelectedFeature;
var layer;
function changeColor() {
if (lastSelectedFeature.feature.id == "1")
{ lastSelectedFeature.feature.style.fillColor = "#F3AF20"; HideContextMenus(); }
else {
lastSelectedFeature.feature.style.fillColor = "#F12B20"; HideContextMenus();
}
layer.redraw();
}
function OnMapCreated(map) {
layer = map.layers[1];
map.layers[1].events.register('featureselected', map.layers[1], function (feature) {
lastSelectedFeature = feature;
});
}
this "layer = map.layers[1];" is empty, but i"map.controls[0]" can get value,but I'm not sure get value is hightlightOverlayer.feature.
for example, after modifications for:
function OnMapCreated(map) {
layer = map.controls[0];
map.controls[0].events.register('featureselected', map.controls[0],function (feature) {
lastSelectedFeature = feature;
});
}”
So for the "lastSelectedFeature = feature; " is not executed, so can not access to the selected Feature And when the right click menu can directly execute the changecolor function without executing the OnMapCreated function,so do not achieve the value of the lastSelectedFeature variable
Hi Li
Would you please try the attached code, we made a little amendment to it, and now you should get the right HighlightOverlay.
Best Regards,
Johnny
Post_11240.txt (924 Bytes)
The txt file cannot be opened
Hi Li,
Thanks for reporting this, following is the content in the .txt, please check it and replace ‘–‘ with ‘<’ and ‘>’
-script type="text/javascript"-
var lastSelectedFeature;
var HighlightLayer;
function changeColor() {
if (lastSelectedFeature.feature.id == "1")
{ lastSelectedFeature.feature.style.fillColor = "#F3AF20"; HideContextMenus(); }
else {
lastSelectedFeature.feature.style.fillColor = "#F12B20"; HideContextMenus();
}
HighlightLayer.redraw();
}
function OnMapCreated(map) {
for (var i = 0; i < map.layers.length; i++) {
if (map.layers.name == "HighlightOverlay") {
HighlightLayer = map.layers;
HighlightLayer.events.register('featureselected', HighlightLayer, function (feature) {
lastSelectedFeature = feature;
});
}
}
}
-/script-
Hope it helps
Johnny