Enhanced MapApp scripting support
- Last UpdatedJul 18, 2024
- 2 minute read
You can dynamically add pins to a map displayed by the MapApp using an action script. The AddContent() function has been added to the MapApp.
MyContent.MapControl1.AddContent(Map_information)
Action script to add one map pin to a map.
' Use "AddContent" to add one map pin for US
dim usMapInfo = new aaGraphic.GraphicInfo;
usMapInfo.GraphicName = "MECRE_KSA.zMAP_ICON_Bottom_Left_3";
usMapInfo.Identity = "US_MapPin1";
usMapInfo.Latitude = 35.99;
usMapInfo.Longitude = -97.99;
' Support MaxZoom/MinZoom
usMapInfo.MinZoom = 15;
MyContent.MapControl1.AddContent(usMapInfo);
As MinZoom=15 in runtime the map pin will only appear if the minimum zoom level is 15. If the MaxZoom is also set then the map pin will only appear between the MinZoom and MaxZoom values.
Action script using an array to add multiple map pins to a map.
' Use "AddContent" with array parameter to add two map pins for Asia
dim asiaMapInfo1 = new aaGraphic.GraphicInfo;
asiaMapInfo1.GraphicName = "MECRE_KSA.zMAP_ICON_Bottom_Left_3";
asiaMapInfo1.Identity = "ASIA_MapPin1";
asiaMapInfo1.Latitude = 30.42;
asiaMapInfo1.Longitude = 149.46;
dim asiaMapInfo2 = new aaGraphic.GraphicInfo;
asiaMapInfo2.GraphicName = "MECRE_KSA.zMAP_ICON_Bottom_Left_3";
asiaMapInfo2.Identity = "ASIA_MapPin2";
asiaMapInfo2.Latitude = 35.42;
asiaMapInfo2.Longitude = 149.46;
dim asiaMapInfo[2] = as aaGraphic.GraphicInfo;
asiaMapInfo[1] = asiaMapInfo1;
asiaMapInfo[2] = asiaMapInfo2;
MyContent.MapControl1.AddContent(asiaMapInfo);
Action scripts can include the Set zoom level range to show or hide map pins that are added.
You can dynamically remove a pin from a map displayed by the MapApp using an action script and the RemoveContent() function. You can also use the ClearAllContents() function to clear all the pins added using the AddContent() function. The RemoveContent() allows you to remove one map pin at a time while the ClearAllContents() function will clear all the pins in one function call.