After the application that uses the flex API to call the National Map of heaven and earth is published to the server, it is found that the "Security Sandbox conflict" error message appears during printing and screenshots.
In fact, this is a flex security policy.
I am familiar with the following two methods to solve such conflicts:
1) Place the crossdomain. xml cross-domain file under the root directory of the Map Server
2) Write proxy
Because the national map server is far away from the capital, basically method 1 is not implemented at present, so it can only be implemented through method 2) Write proxy
I wrote a servlet to implement the proxy map tile service function.
String type = request. getparameter ("T ");
String x = request. getparameter ("X ");
String y = request. getparameter ("Y ");
String L = request. getparameter ("L ");
Long Index = math. Round (math. Random () * 7 );
/*
* A complete image URL has the following format: http://tile0.tianditu.com/DataServer? T = siwei0608 & X = 6666 & Y = 1406 & l = 13
*/
String spec = "http: // tile" + index + ".tianditu.com/dataserver? T = "+ Type +" & X = "+ x +" & Y = "+ Y +" & l = "+ L;
URL url = new URL (SPEC );
Urlconnection = URL. openconnection ();
Urlconnection. Connect ();
Inputstream = urlconnection. getinputstream ();
Response. setcontenttype ("image/PNG ");
Outputstream = response. getoutputstream ();
Byte B [] = new byte [1];
While (-1! = Inputstream. Read (B, 0, 1 ))
Outputstream. Write (B, 0, 1 );
Inputstream. Close ();
Outputstream. Close ();
After the servlet is published, browse the map in the flex API and use the fire bug tracking to find that the tile address obtained by the client is the proxy address released by the local machine.
For example
Http: // localhost: 8080/xtgeomaps_app/gjtianditu? T = siwei0608 & X = 6666 & Y = 1406 & l = 13
Instead
Http://tile0.tianditu.com/DataServer? T = siwei0608 & X = 6666 & Y = 1406 & l = 13
With this proxy method, you can print and print as you like.
It must be noted that, in this proxy method, the client needs to obtain the tiles and pass through two servers, one is the map server of the national World, and the other is the local server, the response speed will certainly be affected.