Part 1ArticleI discussed that calling the rest API of Supermap iServer java6r in Java is relatively direct, and it is difficult to directly spell the URL by myself. Today, I found that interfaces such as restmapprovider are provided in the SP1 version of Supermap iServer java6r, this means that you can directly call the iServer-All jar package.
Preparation:
1. Start the iServer 6R service.
Code:
Use restmapprovider Package Com. awei20081.restmap; Import Com. Supermap. Services. components. commontypes .*; Import Com. Supermap. Services. providers .*; Public Class Testmapprovider {Public Final Static Void Main (string [] ARGs) Throws Exception { /*** Idea: * 1. instantiate the restmapprovider object. * 2. Call the topic diagram interface to set the topic diagram. * 3. Call the getmapimage method of the restmapprovider object to obtain the image. * 4. Enter the URL in the browser to access the URL. */ // Instantiate a restmapprovidersetting Restmapprovidersetting = New Restmapprovidersetting (); // Set the root directory of the rest Service Restmapprovidersetting. restservicerooturl =" HTTP: /localhost: 8090/iServer/services/maps/rest/ ";// Instantiate the restmapprovider object Restmapprovider = New Restmapprovider (restmapprovidersetting ); // Obtain default map Parameters Mapparameter defamapmapparam = restmapprovider. getdefamapmapparameter (" World Map "); Mapparameter currentmapparam = New Mapparameter (defamapmapparam ); // Find the layer set corresponding to the map Layercollection = currentmapparam. layers. Get (0). sublayers; // Clear all layers configured in the map Layercollection. Clear (); // Create a Topic map layer Ugcthemelayer themelayer = New Ugcthemelayer (); themegraph = New Themegraph (); // Use a 3-dimensional pie chart Themegraph. graphtype = themegraphtype. pie3d; // Use the value as the displayed text Themegraph. graphtextformat = graphtextformat. value; // The level size uses the constant mode. Themegraph. graduatedmode = graduatedmode. constant; // Whether the image size is fixed. True indicates that the image size does not scale. Themegraph. graphsizefixed = False ; // Display text Themegraph. graphtextdisplayed = True ; // Display negative values Themegraph. negativedisplayed =True ; Themegraph. Items = New Themegraphitem [2]; themegraphitem item0 = New Themegraphitem (); // The content corresponding to the field sqkm is marked in red. Item0.graphexpression =" Sqkm "; Item0.uniformstyle = New Style (); item0.uniformstyle. fillforecolor = New Color (255,); item0.caption =" 1 "; Themegraphitem Item1 = New Themegraphitem (); // The content corresponding to the field sqmi is expressed in green. Item1.graphexpression ="Sqmi "; Item1.uniformstyle = New Style (); item1.uniformstyle. fillforecolor = New Color (0, 255, 0); item1.caption =" 2 "; Themegraph. items [0] = item0; themegraph. items [1] = Item1; // Set the dataset information, which must be a vector Dataset Datasetvectorinfo datasetinfo = New Datasetvectorinfo (); datasetinfo. Name =" Countries "; Datasetinfo. datasourcename =" World "; Datasetinfo. type = datasettype. region; // Assign a value to the Layer Themelayer. theme = themegraph; themelayer. datasetinfo = datasetinfo; themelayer. opaquerate = 100; // Add to the layers set to display on the map Layercollection. Add (themelayer ); // If the image is not cached, the image is displayed again each time. Currentmapparam. cacheenabled = False ; // Set the image size to 800x800 Currentmapparam. Viewer = New Rectangle (0, 0, 512,512 ); // Set the returned format of the image to the file path. Currentmapparam. returntype = returntype. url; // Instantiate image options Imageoutputoption outputoption = New Imageoutputoption ();// Specify the image format as PNG Outputoption. format = outputformat. PNG; // Call the getmapimage interface to obtain the image object Mapimage = restmapprovider. getmapimage (currentmapparam, outputoption ); // Output image address System. Out. println (mapimage. imageurl. tostring ());}}
Output result:
"Href =" http: // localhost: 8090/iServer/services/maps/rest/maps/% E4 % B8 % 96% E7 % 95% 8C % E5 % 9C % B0 % E5 % 9B % Be/image.png? Viewer = % 7b % 22 lefttop % 22% 3A % 7b % 22y % 22% 3A0% 2C % 22x % 22% 3A0% 7D % 2C % 22 rightbottom % 22% 3A % 7b % 22y % 22% 3a512% 2C % 22x % 22% 3a512% 7D % 7D & cacheenabled = false & rectifytype = bycenterandmapscale & clipregion = % 7b % 22 center % 22% 3 anull % 2C % 22id % 22% 3A0% 2c % 22 style % 22% 3 anull % 2C % 22 parts % 22% 3 anull % 2C % 22 points % 22% 3 anull % 2C % 22 Type % 22% 3A % 22 region % 22% 7d & clipregionenabled = false & customentireboundsenabled = false & angle = 0.0 & antialias = true & colorm Ode = default & dynamicprojection = false & markeranglefixed = false & maxvisibletextsize = 1000.0 & Strong = 3600000 & minvisibletextsize = 0.3 & overlapdisplayed = true & paintbackground = true & textanglefixed = false & Strong = false & center = % 7b % 22y % 22% 3a27. 5734580668% 2C % 22x % 22% 3a96. 1736997712% 7d & scale = 2.563206512274041e-8 & layersid = tu45quuz_fc28ec230a514c45a2217b8db661b191 & imageformat = PNG & nolayers = true & Trans Parent = false "> http: // localhost: 8090/iServer/services/maps/rest/maps/% E4 % B8 % 96% E7 % 95% 8C % E5 % 9C % B0 % E5 % 9B % Be/image.png? Viewer = % 7b % 22 lefttop % 22% 3A % 7b % 22y % 22% 3A0% 2C % 22x % 22% 3A0% 7D % 2C % 22 rightbottom % 22% 3A % 7b % 22y % 22% 3a512% 2C % 22x % 22% 3a512% 7D % 7D & cacheenabled = false & rectifytype = bycenterandmapscale & clipregion = % 7b % 22 center % 22% 3 anull % 2C % 22id % 22% 3A0% 2c % 22 style % 22% 3 anull % 2C % 22 parts % 22% 3 anull % 2C % 22 points % 22% 3 anull % 2C % 22 Type % 22% 3A % 22 region % 22% 7d & clipregionenabled = false & region = false & angle = 0.0 & antialias = true & colormode = default & dynamicprojection = false & region = false & maxvisibletextsize = 1000.0 & maxvisiblevertex = 3600000 & minvisibletextsize = 0.3 & overlapdisplayed = true & paintbackground = true & textanglefixed = false & textorientationfixed = false & center = % 7b % 22y % 22% 3a27. 5734580668% 2C % 22x % 22% 3a96. 1736997712% 7d & scale = 2.563206512274041e-8 & layersid = tu45quuz_fc28ec230a514c45a2217b8db661b191 & imageformat = PNG & nolayers = true & transparent = false
Enter browsing test to get the following result:
The restmapprovider interface is simply used here.ProgramTo create a small C/S system.