Select to view content in your preferred language

PictureMarkerSymbol with SWF not visible until Map zoomed

1446
8
11-05-2010 10:16 AM
Ranga_RaoGadiparthi
New Contributor
I am trying to add a red glow symbol on a the Map using picturemarkersymbol.
I can't see the glow symbol, until I zoom/move the map.
I am using flex esri lib 2.1.

Here is the sample code.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:mx="library://ns.adobe.com/flex/mx"
      xmlns:esri="http://www.esri.com/2008/ags"
      xmlns:s="library://ns.adobe.com/flex/spark"
      pageTitle="Petroleum Wells in Kansas 1889-2009" xmlns:symbols="com.esri.ags.symbols.*">
<!--
This sample shows you how to use a time-aware dynamic service to your application.

ArcGIS Server 10 has built-in support for Time-Aware layers. On the server you
can specify a certain field as a special Time field. This time field can be used
to set time extent and only ask for data covering certain times. Using a
DynamicLayer we get full time extent metadata from the server.
-->

<s:layout>
  <s:VerticalLayout horizontalAlign="center"
        paddingBottom="10"
        paddingTop="10"/>
</s:layout>

<fx:Style>
  @namespace mx "library://ns.adobe.com/flex/mx";
 
  mx|ToolTip {
   font-size: 16;
  }
</fx:Style>

<fx:Declarations>
  <mx:DateFormatter id="myDateFormatter" formatString="MMMM D, YYYY"/>
</fx:Declarations>

<fx:Script>
  <![CDATA[
   import com.esri.ags.Graphic;
   import com.esri.ags.events.LayerEvent;
   import com.esri.ags.events.MapMouseEvent;
   import com.esri.ags.geometry.Extent;
   import com.esri.ags.utils.WebMercatorUtil;
  
   protected function myTimeLayer_loadHandler(event:LayerEvent):void
   {
    // myMap.extent = WebMercatorUtil.geographicToWebMercator(myTimeLayer.initialExtent) as Extent;
    myFirstTimeSlider.createTimeStopsByCount(myTimeLayer.timeInfo.timeExtent); // defaults to 10 intervals
   }
   protected function nysMap_mapClickHandler(event:MapMouseEvent):void
   {
    const gra:Graphic = new Graphic(event.mapPoint,pms_embedded);
    topLayer.add(gra);
   }  
  ]]>
</fx:Script>
<fx:Declarations>
  <symbols:PictureMarkerSymbol id="pms_embedded" source="@Embed(source='/assets/Red_glow.swf')" width="40" height="40" />
</fx:Declarations>


<s:Label fontSize="20" text="Petroleum Wells in Kansas 1889-2009"/>
<s:Label fontSize="14" text="... up to {myDateFormatter.format(myFirstTimeSlider.timeExtent.endTime)}"/>

<!-- Step 1. Create the time slider                              -->
<!-- Step 2. Give the map a time slider (to make it time-aware). -->
<!-- Step 3. Set the time extent of the time slider              -->

<esri:Map id="myMap" timeSlider="{myFirstTimeSlider}" mapClick="nysMap_mapClickHandler(event)">
  <esri:extent>
   <esri:Extent xmin="-10854962" ymin="4514317" xmax="-10779136" ymax="4572944">
    <esri:SpatialReference wkid="102100"/>
   </esri:Extent>
  </esri:extent>
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
  <esri:ArcGISDynamicMapServiceLayer id="myTimeLayer"
             load="myTimeLayer_loadHandler(event)"
             url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSWells/MapServer">
   <!-- this service has all layers turned off by default, so we turn some of them "on" -->
   <esri:visibleLayers>
    <mx:ArrayCollection>
     <fx:Number>0</fx:Number>
     <fx:Number>1</fx:Number>
    </mx:ArrayCollection>
   </esri:visibleLayers>
  </esri:ArcGISDynamicMapServiceLayer>
  <esri:GraphicsLayer id="topLayer"/>
</esri:Map>

<esri:TimeSlider id="myFirstTimeSlider"/>
<s:Label text="This map has one time-aware layer: a dynamic service showing wells."/>
</s:Application>
Tags (2)
0 Kudos
8 Replies
MehulChoksey
Esri Contributor
Thanks for reporting this.
Removing width and height from the pictureMarkerSymbol makes it work (ofcourse without the required size of the swf.)

Mehul
0 Kudos
SarthakDatt
Frequent Contributor
Ranga,

This is a bug right now in the 2.x Flex API version. The bug is for embedded swfs, when setting width/height.

As a workaround for now, you can either use the swf with the default size or try creating one beforehand with the size you want.

Hope that helps.
0 Kudos
Ranga_RaoGadiparthi
New Contributor
Ranga,

This is a bug right now in the 2.x Flex API version. The bug is for embedded swfs, when setting width/height.

As a workaround for now, you can either use the swf with the default size or try creating one beforehand with the size you want.

Hope that helps.


Thanks Sarthak.
0 Kudos
DavidMarley
Frequent Contributor
Is this width/height of SWF issue still a bug as of version 2.2 of the API?
0 Kudos
MehulChoksey
Esri Contributor
Yes this is still an issue.
0 Kudos
XianzhuYue
New Contributor
Yes this is still an issue.


Is this width/height of SWF issue still a bug as of version 3.2 of the Flex API?
0 Kudos
ThaoLe
by
Regular Contributor
Is this width/height of SWF issue still a bug as of version 3.2 of the Flex API?


I tested with the Flex API 2.3 and can verify that the issue with the SWF not loading is no longer there. Here's the MXML that I used:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:s="library://ns.adobe.com/flex/spark" 
      xmlns:mx="library://ns.adobe.com/flex/mx"
      xmlns:esri="http://www.esri.com/2008/ags" minWidth="955" minHeight="600" viewSourceURL="srcview/index.html">
 <fx:Script>
  <![CDATA[
   import com.esri.ags.Graphic;
   import com.esri.ags.events.ExtentEvent;
   import com.esri.ags.events.ZoomEvent;
   import com.esri.ags.geometry.MapPoint;
   import com.esri.ags.symbols.PictureMarkerSymbol;
   
   private var initRes:Number;
   private var initW:int;
   private var initH:int;
   private var pm:PictureMarkerSymbol;
   private var pmg:Graphic;
   private var myGraphicMarker:Graphic;
   
   private function cc():void
   {    
    map.addEventListener(ExtentEvent.EXTENT_CHANGE, extentChange);
    map.centerAt(new MapPoint(-72.185684,41.323083));
    
    function extentChange(event:ExtentEvent):void
    {
     map.removeEventListener(ExtentEvent.EXTENT_CHANGE, extentChange);
     
     map.addEventListener(ZoomEvent.ZOOM_END, zoomFinished);
     map.addEventListener(ExtentEvent.EXTENT_CHANGE, ec);
     //'assets/image_swf7.swf'
     //'assets/01.png'
     pm = new PictureMarkerSymbol('assets/Red_glow.swf');
     pm.yoffset = 20;
     //if I set this width and height initially, the SWF doesn't load
     //if I don't, the width and height aren't registered with the PictureMarkerSymbol...
     //so I can't probably resize and offset the SWF
     //pm.height = 656;
     //pm.width = 975;
     
     pmg = new Graphic(new MapPoint(-72.185684,41.323083));
     pmg.mouseEnabled = false;
     pmg.mouseChildren = false;
     pmg.symbol = pm;
     myGraphicsLayer.add(pmg);
     
     myGraphicMarker = new Graphic(new MapPoint(-72.185684,41.323083));
     myGraphicsLayer.add(myGraphicMarker);
     
     initRes = map.lods[map.level].resolution;
     
     initW = 975;
     initH = 656;
    }
   }
   private function zoomFinished(event:ZoomEvent):void
   {
    trace("zoom finished");
    
    pm.height = initH * 1/(map.lods[map.level].resolution/initRes);
    pm.width = initW * 1/(map.lods[map.level].resolution/initRes);
    pmg.height = initH * 1/(map.lods[map.level].resolution/initRes);
    pmg.width = initW * 1/(map.lods[map.level].resolution/initRes);
    
    trace(pm.height);
    trace(pm.width);
    
    //pm.xoffset = -(initW * 1/(map.lods[map.level].resolution/initRes)) / 2;
    //pm.yoffset = (initH * 1/(map.lods[map.level].resolution/initRes)) / 2;
   }
   private function ec(event:ExtentEvent):void
   {
    trace("extent changed");
    
    pm.height = initH * 1/(map.lods[map.level].resolution/initRes);
    pm.width = initW * 1/(map.lods[map.level].resolution/initRes);
    pmg.height = initH * 1/(map.lods[map.level].resolution/initRes);
    pmg.width = initW * 1/(map.lods[map.level].resolution/initRes);
    
    trace(pm.height);
    trace(pm.width);
   }
   
  ]]>
 </fx:Script>
 
 <esri:Map id="map" level="7" load="cc()" >
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" />
  <esri:GraphicsLayer id="myGraphicsLayer" />
 </esri:Map>
</s:Application>
0 Kudos
tianbaowen
New Contributor
hi, I met a different bug with swf and png.when zooming the map,the locations of swf  and png are not in the same place(with the same point).
here is the url     http://forums.arcgis.com/threads/50864-Flex-API-2.5-PictureMarkerSymbol-load-swf-bug?p=173886&posted...
0 Kudos