WMS services are relatively simple to load and require only a minimal set of parameters, allowing them to be created directly through the API.
WMTS services are more complex and require numerous parameters, including tile matrices, resolutions, and bounding box definitions. For this reason, the recommended approach is to create the WMTS layer using the TerraExplorer user interface and then extract the generated initialization parameters.
Example implementations for both methods are provided in the attached FLY file.
Load WMS Using the TerraExplorer Desktop API
ExtInfo definition containing the WMS URL, bounding box, coordinate system, and optional rendering parameters.Construct an ExtInfo string that defines the WMS service parameters.
Pass the ExtInfo string to
CreateImageryLayer, along with the appropriate plugin name.
var WmsInit = "<EXT><ExtInfo><![CDATA[[INFO]\n" +
"ProtocolType = 2\n" +
"Meters = 1\n" +
"MPP = 0.1\n" +
"Url = https://SampleSite.com/arcgis/services/Secure/ReferentielVA/MapServer/WmsServer?token=Tyk5_0rd21B9wmub1loFkXuH1LiPFwkOkz9DGkFvI7vV0o6w5-6sjcimj0SmILSsW8-g1tuVKMF3FI8T4bMMWr0MWGfJS3_tMAcFiv01y6E4M1cmxjafuCLbNX26qTMR2HT6oQlDwvep0vHa9oPCtnIoRygklqWGIc3_wmkjwvxEHU&request=GetMap&Version=1.3.0&Service=WMS&CRS=EPSG:2155&BBOX=314625.8026,6151560.4571,1064564.99,6866844.484&HEIGHT=488&WIDTH=512&Layers=3&Styles=default&Format=image/png&TRANSPARENT=TRUE\n" +
"CapabilitiesUrl = https://SampleSite.com/arcgis/services/Secure/ReferentielVA/MapServer/WMSServer?\n" +
"xul = 314625.802600\n" +
"ylr = 6151560.457100\n" +
"xlr = 1064564.990000\n" +
"yul = 6866844.484000\n" +
"ReadSizeX = 512\n" +
"ReadSizeY = 512\n" +
"WKT = PROJCS[\"RGF93 / Lambert-93\", GEOGCS[\"RGF93\", DATUM[\"Reseau_Geodesique_Francais_1993\", SPHEROID[\"GRS 1980\", 6378137, 298.257222101]], UNIT[\"degree\",0.0174532925199433]], PROJECTION[\"Lambert_Conformal_Conic_2SP\"], PARAMETER[\"standard_parallel_1\",49], PARAMETER[\"standard_parallel_2\",44], PARAMETER[\"latitude_of_origin\",46.5], PARAMETER[\"central_meridian\",3], PARAMETER[\"false_easting\",700000], PARAMETER[\"false_northing\",6600000], UNIT[\"metre\",1]]\n" +
"ReplaceXY = 0\n" +
"]]></ExtInfo><ExtType>wms</ExtType></EXT>";
SGWorld81.Creator.CreateImageryLayer(
"My Layer",
0.0, 0.0, 0.0, 0.0,
WmsInit,
"GISplg.rct",
"",
"New WMS Layer"
);Load WMTS Using TerraExplorer Desktop API
Creating a WMTS layer manually requires specifying many parameters, including tile matrices, resolutions, bounding boxes, and server tile structure. Because of this complexity, TerraExplorer provides a UI object that automatically generates the required initialization parameters.
- In TerraExplorer, add the WMTS layer using Add Layer → WMTS.
- In a script message, access the layer's initialization parameters using
This81.InitParamandThis81.PlugName - Pass these parameters to
CreateImageryLayerto recreate the layer programmatically.
SGWorld81.Creator.CreateImageryLayer(
"",
0, 0, 0, 0,
This81.InitParam,
This81.PlugName,
"",
"Duplicated WMS Layer"
);