I am trying to achieve the following:
I'd like to use a png file as the marker symbol for my PictureMarkerSymbol, but it seems like it's only possible with local png files
What doesn't work, but I'd like to achieve:
var markerSymbol = {
type: "picture-marker",
url: "https://www.myurltothepicture.com/img/mypicture.png",
height: "60px",
width: "60px",
};
What works, but isn't what I need:
var markerSymbol = {
type: "picture-marker",
url: "local/path/to/png/symbol.png",
height: "60px",
width: "60px",
};
Does anybody know if this is generally not possible, or am I doing something wrong?
I'm using JS API 4.15
Thanks in advance for your help
Solved! Go to Solution.
Yeah, the easiest way is to use an image hosted on the same domain as the application. That works, as you have already noted.
Alternatively:
To avoid CORS issues with this symbol, do one of the following:
- Make certain that the image is hosted on a CORS enabled server.
- Use an image hosted on the same domain as the application.
- Install a proxy.
More info here: PictureMarkerSymbol | ArcGIS API for JavaScript 4.15
HTH,
Egge-Jan
Yeah, the easiest way is to use an image hosted on the same domain as the application. That works, as you have already noted.
Alternatively:
To avoid CORS issues with this symbol, do one of the following:
- Make certain that the image is hosted on a CORS enabled server.
- Use an image hosted on the same domain as the application.
- Install a proxy.
More info here: PictureMarkerSymbol | ArcGIS API for JavaScript 4.15
HTH,
Egge-Jan
Thanks Egge-Jan Pollé then I got it right, but it's not possible to simply add something like this to the url property?
url: "https://i.stack.imgur.com/ILTQq.png"
No, apparently not... When your image is hosted in a different domain as the application, you should make sure that the server the image is hosted on is CORS enabled. Or you should install a proxy...
When I tried this sometime ago (Aan de slag met ArcGIS JavaScript - CSV bestand toevoegen), I ended up using the most simple solution: I copied the image to my own server. I did not (not yet) get one of the other two options to work, so I am not able to give you any insights into these...
BR,
Egge-Jan
Thanks Egge-Jan Pollé that's exactly what I've done right now, because it's the easiest way.