Today I’m going to show you how to draw an icon on the map and how to make it change with map zoom. For this example I chose to mark Offroad on the map with white icon. As you will see later on the video this method is far superior to the default method of marking units in Arma 3. For starters it is possible to make icon proportionate to the map zoom and make it reflect real size of the unit. It also is much smoother while the default icon lags and skips, and this is just in the editor.
Anyway, there is a dedicated event handler for drawing things on map which is called “Draw”. It will fire every frame when the map is open. It could be the normal map or any custom map control you create. Once it is shown, “Draw” will fire. To draw actual icon there is drawIcon command. As you have guessed it also has to be drawn every frame. This command takes icon dimensions and direction. If you leave dimensions static, it will draw icon proportionate to your screen and therefore the icon will always be the same size when you zoom in or zoom out the map. To make it change with the map you need to somehow connect it with map zoom.
This is where ctrlMapScale command comes in handy. Map scale is 1 when fully zoomed out, and it decreases in value as you zoom in. So to make icon smaller while map detail gets bigger we need to invert something. I decided to invert map scale by using 0.5/ctrlMapScale for icon size. The value of ctrlMapScale can be very small but never 0 so it is safe in this formula. Why 0.5? This is trial and error value for Offroad icon to keep icon size proportionate to the rest of map markings and it depends on the size of the icon image. Oh yeah, the normal UI map control is 51 of display 12. I also made map auto centre on player with mapCenterOnCamera. And here is the code:
UPDATE: After 2 evenings of experiments with this command, I finally figured what kind of units it takes for the size. drawRectangle for example is very simple, it takes metres and is relative to the map positioning, but drawIcon size is different, even if it looks very similar to drawRectangle. Basically this command is relative to the viewport, which is unified 4:3 area in the middle of the screen. In screen units, the viewport size is 1 by 1. So if you were to draw the icon to fit viewport with drawIcon you would need to use (640 * 1) for width and (480 * 1) for height. If you wanted to draw the icon the size of the whole screen, the width of it would be (640 * safeZoneW) and the height of it would be (480 * safeZoneH).