esri|PopUpRenderer { skin-class: ClassReference("com.esri.viewer.skins.customPopUpRendererSkin"); }
Dilson, If you want to do something different than what the provided code does than you will have to learn to program it yourself (all the programming is not always going to be done for you, unless you hire a programmer). Here is a thread where I show someone how to flash a feature graphic on the map:http://forums.arcgis.com/threads/104402-GPS-coordinates-inputing-a-graphic
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).
Yes that would be nice, and it's doable.You can get the PopUpRendererSkin.mxml from downloading the API and make some addition there to accomplish this.My solution is probably not the best one, but it works for me. Basically I'm adding the feature to a new graphiclayer and put a glow filter on it.Here's my customPopUpRendererSkin, my additions are commented so you can see what I've done and change to your own customizations. For example make it flash insted of beeing highlighted or whatever you want.Copy the skin to for example src/com/esri/viewer/skinsand then point it out in the defaults.css, something like this:esri|PopUpRenderer { skin-class: ClassReference("com.esri.viewer.skins.customPopUpRendererSkin"); }I'm still in version 2.4, and my customPopUpRendererSkin is based on the one from API 2.4. If you have 2.5, download that new skin and make the changes to that one...
Dilson, Hmm... I really can not tell you where you are going wrong then. When I have a change to the highlightColor var it works fine.
Dilson, That is just a warning, that the import in not actually used in the code and could be removed. If you ever had the ability to resize your popups then you already had a customized popup skin, as resizing the popup is not a OTB feature.
I have problem when trying to resize the results box, it's fall to the bottom of the screen. Seems like i lost some control to resize results box
Dilson, Sure. I just threw it into 2.5 of the viewer and it worked fine.
... ... 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(); }
Robert,I get a warning error 3596 - Duplicate Variable Definition forvar 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;
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); } }
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); } } }
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.