Refresh of PictureMarkerSymbol source image issue.

759
2
Jump to solution
02-27-2020 01:38 AM
MarkSmith
New Contributor III

Hello,

 

I posted this question back in 2014 and didn't get any responses.  I must have found an alternative approach back then, but now I need to do it again and I'm still stuck.  I have a graphics refresh issue.  I'm adding a PictureMarkerSymbol into a graphics layer which has a png image as its source url.

  

        var theSymbol = new esri.symbol.PictureMarkerSymbol({ 

            "url": "IMAGES/TestImage.png", 

            "height": 30, 

            "width": 30 

        }); 

        var mapPoint = new esri.geometry.Point(350000, 900000, new esri.SpatialReference({ wkid: 27700 })); 

        var graphic = new esri.Graphic(mapPoint, theSymbol); 

        customGraphicsLayer.add(graphic); 

  

This works fine, but the problem is the source png image changes periodically (but the name TestImage.png remains the same), it's updated externally and I need the graphic icon on the map to update when the user clicks an update button (actually I've only added a button for testing, ultimately I'll automate it).  However I can't get the API/browser to forget about the previous image.  I've tried clearing the graphics, removing the graphics layer and adding it again, and adding a new PictureMarkerSymbol after I know the source png image has changed, but it seems that once the API/browser knows about the original image it assumes it hasn't changed and re-uses the original image from somewhere in its memory.  Doing a full page refresh isn't really an option.

  

Can anyone suggest how I can make sure my PictureMarkerSymbol grabs the latest image, not what it thinks the image is from the API/browser cache?

  

Thank you.

 

Mark

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Mark,

   Have you thought about standard cache busting methods? You can append a epoch time parameter to the url like:

"url": "IMAGES/TestImage.png?time=1582810487". So when you know the image has been updated or just on some interval, you can use the current epoch time to append to the url and this will froce the browser to NOT use the cached image.

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Mark,

   Have you thought about standard cache busting methods? You can append a epoch time parameter to the url like:

"url": "IMAGES/TestImage.png?time=1582810487". So when you know the image has been updated or just on some interval, you can use the current epoch time to append to the url and this will froce the browser to NOT use the cached image.

MarkSmith
New Contributor III

Thanks Robert, that worked, good idea.

0 Kudos