Solved! Go to Solution.
esri|PopUpRenderer { skin-class: ClassReference("com.esri.viewer.skins.customPopUpRendererSkin"); }esri|PopUpRenderer { skin-class: ClassReference("com.esri.viewer.skins.customPopUpRendererSkin"); } override protected function commitProperties():void
{
super.commitProperties();
var featureLayer:FeatureLayer = hostComponent.featureLayer;
var formattedAttributes:Object = hostComponent.formattedAttributes;
var graphic:Graphic = hostComponent.graphic;
var map:Map = hostComponent.map;
var popUpInfo:PopUpInfo = hostComponent.popUpInfo;
var validMediaInfos:Array = hostComponent.validPopUpMediaInfos;
var geometry:Geometry = graphic ? graphic.geometry : null;
var layerDetails:LayerDetails = featureLayer ? featureLayer.layerDetails : null;
//Make sure there is a graphic
if(graphic){
var gf:spark.filters.GlowFilter = new spark.filters.GlowFilter();
gf.color = 0xFF0000;
gf.alpha = 1;
gf.strength = 2;
gf.blurX = 8;
gf.blurY = 8;
var hlGraphicLayer:GraphicsLayer;
//Attempt to retieve the highlightGraphics layer
hlGraphicLayer = map.getLayer("highlightGraphics") as GraphicsLayer;
//If it does not exist create it.
if(!hlGraphicLayer){
hlGraphicLayer = new GraphicsLayer();
hlGraphicLayer.id = "highlightGraphics";
map.addLayer(hlGraphicLayer);
}
hlGraphicLayer.clear();
//Create the new highlight graphic
const hlGraphic:Graphic = new Graphic(graphic.geometry, graphic.symbol,graphic.attributes);
switch(graphic.geometry.type){
case Geometry.MAPPOINT:{
hlGraphic.symbol = new SimpleMarkerSymbol("circle",22,0x000000,0,0,0,0,new SimpleLineSymbol("solid",0xFF0000,0.5,2));
break;
}
case Geometry.POLYLINE:{
hlGraphic.symbol = new SimpleLineSymbol("solid",0xFF0000,0.3,8);
break;
}
default:{
hlGraphic.symbol = new SimpleFillSymbol("solid",0x000000,0,new SimpleLineSymbol("solid",0xFF0000,0.4,3));
break;
}
}
hlGraphic.filters = [gf];
hlGraphicLayer.add(hlGraphic);
//Add inline event listener functions for removing the highlight graphic
map.infoWindow.closeButton.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void{infoWindowClose(event, hlGraphicLayer)});
function infoWindowClose(evt:Event, graphicLay:GraphicsLayer):void{
graphicLay.clear();
graphicLay.refresh();
graphicLay.map.infoWindow.closeButton.removeEventListener(MouseEvent.CLICK, infoWindowClose);
}
map.addEventListener(MapMouseEvent.MAP_CLICK, function(event:MouseEvent):void{onMapClick(event, hlGraphicLayer)});
function onMapClick(evt:Event, graphicLay:GraphicsLayer):void{
graphicLay.clear();
graphicLay.refresh();
graphicLay.map.removeEventListener(MapMouseEvent.MAP_CLICK, onMapClick);
}
}
vGroup.removeAllElements();
//vGroup.addElement(ToggleLayers);
if (popUpInfo)
{
if (popUpInfo.title)
{
titleText.text = StringUtil.substitute(popUpInfo.title, formattedAttributes);
if (titleText.text)
{
vGroup.addElement(titleText);
vGroup.addElement(titleLine);
}
}
var htmlText:String;
if (popUpInfo.description)
{
htmlText = StringUtil.substitute(popUpInfo.description, formattedAttributes);
if (htmlText)
{
var descriptionText:Text = new PopUpText();
descriptionText.percentWidth = 100;
descriptionText.styleSheet = textStyleSheet;
cleanAndSetHtmlText(descriptionText, htmlText);
//trace(descriptionText.htmlText);
vGroup.addElement(descriptionText);
}
}
else
{
var descriptionForm:Form;
for each (var fieldInfo:PopUpFieldInfo in popUpInfo.popUpFieldInfos)
{
if (fieldInfo.visible)
{
var formItem:FormItem = new FormItem();
formItem.label = fieldInfo.label || fieldInfo.fieldName;
var label:Label;
htmlText = formattedAttributes[fieldInfo.fieldName];
if (htmlText)
{
// convert attribute field values that just contain URLs into links
var match:Array = htmlText.match(/^\s*((https?|ftp):\/\/\S+)\s*$/i);
if (match && match.length > 0)
{
label = new Label();
htmlText = '<a href="' + match[1] + '" target="_blank">' + match[1] + "</a>";
}
else
{
label = new PopUpText();
}
cleanAndSetHtmlText(label, htmlText);
label.selectable = true;
label.styleSheet = this.textStyleSheet;
label.width = 150;
formItem.addChild(label);
}
if (!descriptionForm)
{
descriptionForm = new Form();
descriptionForm.percentWidth = 100;
descriptionForm.horizontalScrollPolicy = ScrollPolicy.OFF;
descriptionForm.verticalScrollPolicy = ScrollPolicy.OFF;
descriptionForm.styleName = "formStyle";
}
descriptionForm.addChild(formItem);
}
}
if (descriptionForm)
{
vGroup.addElement(descriptionForm);
}
}
if (validMediaInfos && validMediaInfos.length > 0)
{
vGroup.addElement(mediaBrowser);
mediaBrowser.attributes = graphic.attributes;
mediaBrowser.formattedAttributes = formattedAttributes;
mediaBrowser.popUpFieldInfos = popUpInfo.popUpFieldInfos;
mediaBrowser.popUpMediaInfos = validMediaInfos;
}
if (popUpInfo.showAttachments && graphic && featureLayer
&& layerDetails && layerDetails.hasAttachments && layerDetails.objectIdField)
{
vGroup.addElement(attachmentInspector);
attachmentInspector.showAttachments(graphic, featureLayer);
}
if (map && geometry)
{
vGroup.addElement(zoomToButton);
}
}
}
override protected function commitProperties():void
{
super.commitProperties();
var featureLayer:FeatureLayer = hostComponent.featureLayer;
var formattedAttributes:Object = hostComponent.formattedAttributes;
var graphic:Graphic = hostComponent.graphic;
var map:Map = hostComponent.map;
var popUpInfo:PopUpInfo = hostComponent.popUpInfo;
var validMediaInfos:Array = hostComponent.validPopUpMediaInfos;
var geometry:Geometry = graphic ? graphic.geometry : null;
var layerDetails:LayerDetails = featureLayer ? featureLayer.layerDetails : null;
//Make sure there is a graphic
if(graphic){
var gf:spark.filters.GlowFilter = new spark.filters.GlowFilter();
gf.color = 0xFF0000;
gf.alpha = 1;
gf.strength = 2;
gf.blurX = 8;
gf.blurY = 8;
var hlGraphicLayer:GraphicsLayer;
//Attempt to retieve the highlightGraphics layer
hlGraphicLayer = map.getLayer("highlightGraphics") as GraphicsLayer;
//If it does not exist create it.
if(!hlGraphicLayer){
hlGraphicLayer = new GraphicsLayer();
hlGraphicLayer.id = "highlightGraphics";
map.addLayer(hlGraphicLayer);
}
hlGraphicLayer.clear();
//Create the new highlight graphic
/* const hlGraphic:Graphic = new Graphic(graphic.geometry, graphic.symbol,graphic.attributes); */
const hlGraphic:Graphic = new Graphic(graphic.geometry, graphic.symbol,graphic.attributes);
switch(graphic.geometry.type){
case Geometry.MAPPOINT:{
hlGraphic.symbol = new SimpleMarkerSymbol("circle",22,0x000000,0,0,0,0,new SimpleLineSymbol("solid",0xFF0000,0.5,2));
break;
}
case Geometry.POLYLINE:{
hlGraphic.symbol = new SimpleLineSymbol("solid",0xFF0000,0.3,8);
break;
}
default:{
hlGraphic.symbol = new SimpleFillSymbol("solid",0x000000,0,new SimpleLineSymbol("solid",0xFF0000,0.4,3));
break;
}
}
hlGraphic.filters = [gf];
hlGraphicLayer.add(hlGraphic);
//Add inline event listener functions for removing the highlight graphic
map.infoWindow.closeButton.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void{infoWindowClose(event, hlGraphicLayer)});
function infoWindowClose(evt:Event, graphicLay:GraphicsLayer):void{
graphicLay.clear();
graphicLay.refresh();
graphicLay.map.infoWindow.closeButton.removeEventListener(MouseEvent.CLICK, infoWindowClose);
}
map.addEventListener(MapMouseEvent.MAP_CLICK, function(event:MouseEvent):void{onMapClick(event, hlGraphicLayer)});
function onMapClick(evt:Event, graphicLay:GraphicsLayer):void{
graphicLay.clear();
graphicLay.refresh();
graphicLay.map.removeEventListener(MapMouseEvent.MAP_CLICK, onMapClick);
}
}
vGroup.removeAllElements();
//vGroup.addElement(ToggleLayers);
if (popUpInfo)
{
if (popUpInfo.title)
{
titleText.text = StringUtil.substitute(popUpInfo.title, formattedAttributes);
if (titleText.text)
{
vGroup.addElement(titleText);
vGroup.addElement(titleLine);
}
}
var htmlText:String;
if (popUpInfo.description)
{
htmlText = StringUtil.substitute(popUpInfo.description, formattedAttributes);
if (htmlText)
{
var descriptionText:Text = new PopUpText();
descriptionText.percentWidth = 100;
descriptionText.styleSheet = textStyleSheet;
cleanAndSetHtmlText(descriptionText, htmlText);
//trace(descriptionText.htmlText);
vGroup.addElement(descriptionText);
}
}
else
{
var descriptionForm:Form;
for each (var fieldInfo:PopUpFieldInfo in popUpInfo.popUpFieldInfos)
{
if (fieldInfo.visible)
{
var formItem:FormItem = new FormItem();
formItem.label = fieldInfo.label || fieldInfo.fieldName;
var label:Label;
htmlText = formattedAttributes[fieldInfo.fieldName];
if (htmlText)
{
// convert attribute field values that just contain URLs into links
var match:Array = htmlText.match(/^\s*((https?|ftp):\/\/\S+)\s*$/i);
if (match && match.length > 0)
{
label = new Label();
htmlText = '<a href="' + match[1] + '" target="_blank">' + match[1] + "</a>";
}
else
{
label = new PopUpText();
}
cleanAndSetHtmlText(label, htmlText);
label.selectable = true;
label.styleSheet = this.textStyleSheet;
label.width = 150;
formItem.addChild(label);
}
if (!descriptionForm)
{
descriptionForm = new Form();
descriptionForm.percentWidth = 100;
descriptionForm.horizontalScrollPolicy = ScrollPolicy.OFF;
descriptionForm.verticalScrollPolicy = ScrollPolicy.OFF;
descriptionForm.styleName = "formStyle";
}
descriptionForm.addChild(formItem);
}
}
if (descriptionForm)
{
vGroup.addElement(descriptionForm);
}
}
if (validMediaInfos && validMediaInfos.length > 0)
{
vGroup.addElement(mediaBrowser);
mediaBrowser.attributes = graphic.attributes;
mediaBrowser.formattedAttributes = formattedAttributes;
mediaBrowser.popUpFieldInfos = popUpInfo.popUpFieldInfos;
mediaBrowser.popUpMediaInfos = validMediaInfos;
}
if (popUpInfo.showAttachments && graphic && featureLayer
&& layerDetails && layerDetails.hasAttachments && layerDetails.objectIdField)
{
vGroup.addElement(attachmentInspector);
attachmentInspector.showAttachments(graphic, featureLayer);
}
if (map && geometry)
{
vGroup.addElement(zoomToButton);
}
}
Robert,
I get a warning error 3596 - Duplicate Variable Definition for
var gf:spark.filters.GlowFilter = new spark.filters.GlowFilter();
const hlGraphic:Graphic = new Graphic(graphic.geometry, graphic.symbol,graphic.attributes);
import com.esri.ags.Graphic; import com.esri.ags.layers.GraphicsLayer; import com.esri.ags.Map; import com.esri.ags.geometry.Extent; import com.esri.ags.geometry.Geometry; import com.esri.ags.geometry.MapPoint; import com.esri.ags.geometry.Multipoint; import com.esri.ags.layers.FeatureLayer; import com.esri.ags.layers.supportClasses.LayerDetails; import com.esri.ags.skins.supportClasses.AttachmentMouseEvent; import com.esri.ags.skins.supportClasses.PopUpText; import com.esri.ags.utils.StringUtil; import com.esri.ags.webmap.supportClasses.PopUpFieldInfo; import com.esri.ags.webmap.supportClasses.PopUpInfo; import com.esri.ags.events.MapMouseEvent; //Added for popup customization import com.esri.ags.symbols.SimpleFillSymbol; import com.esri.ags.symbols.SimpleLineSymbol; import com.esri.ags.symbols.SimpleMarkerSymbol; import com.esri.ags.symbols.PictureMarkerSymbol; import spark.filters.GlowFilter; import mx.containers.Form; import mx.containers.FormItem; import mx.controls.Label; import mx.core.ScrollPolicy; import mx.events.FlexEvent;
...
...
map.addEventListener(MapMouseEvent.MAP_CLICK, function(event:MouseEvent):void{onMapClick(event, hlGraphicLayer)});
function onMapClick(evt:Event, graphicLay:GraphicsLayer):void{
graphicLay.clear();
graphicLay.refresh();
graphicLay.map.removeEventListener(MapMouseEvent.MAP_CLICK, onMapClick);
graphicLay.map.infoWindow.hide();
}
All,
So here is the full file with Mattias last addition and a new private var at the top where you can set the highlight color (if you don't want Red).