<script type="text/javascript" src="
http://api.tianditu.com/js/maps.js"></script>
<script type="text/javascript" src="
http://api.tianditu.com/js/service.js"></script>
<title>è¡æ¿åºå</title>
<script type="text/javascript">
var zoom = 10;
var wmsLayer;
var localsearch;
var map;
var lay;
function onLoad() {
var config = { projection: "EPSG:4326"}
//mapå®ä¾
map = new TMap("mapDiv",config);
//设置æ¾ç¤ºå°å¾çä¸å¿ç¹å级å«
map.centerAndZoom(new TLngLat(106.38848,38.995728), zoom);
//å
è®¸é¼ æ æ»è½®ç¼©æ¾å°å¾
map.enableHandleMouseScroll();
//å
许åå»å°å¾æ¾å¤§
map.enableDoubleClickZoom();
getWMS();
}
function getWMS(){
if(wmsLayer)
{
map.removeLayer(wmsLayer);
}
var config = {
REQUEST:"GetMap", //æä½å称
VERSION:"1.1.1", //请æ±æå¡ççæ¬
SERVICE:"WMS", //æå¡ç±»åæ è¯ç¬¦
LAYERS:"0", //ç¨","åéçå¤ä¸ªå¾å±å表
TRANSPARENT:true, //è¾åºå¾åèæ¯æ¯å¦éæ
STYLES:"default", //æ¯ä¸ªè¯·æ±å¾å±çç¨","åéçæè¿°æ ·å¼
FORMAT:"image/png", //è¾åºå¾åçç±»å
SRS:"EPSG:4326", //å°å¾æ影类å
WIDTH:256, //è¾åºå°å¾å¾ççåç´ å®½
HEIGHT:256 //è¾åºå°å¾å¾ççåç´ é«
};
wmsLayer = new TTileLayerWMS("wms","url",config);
//å°WMSå¾å±æ·»å å°å°å¾ä¸
map.addLayer(wmsLayer);
}
</script>
注æäºé¡¹ï¼
1.é¦å
å 为è°ç¨çæ¯å¤©å°å¾çæ·»å wmså¾å±çæ¹æ³ï¼æ以对äºarcgisåå¸çå¾å±æå¡ï¼è¦æ±å¿
é¡»å¯ç¨wmsæå¡åè½æå¯ä»¥ãå¯ç¨çæ¶åä¼æä¸ä¸ªå°åï¼è¿ä¸ªå°åå°±æ¯ä¸é¢urlçå°å
2.å¨åå§åå°å¾çæ¶åvar config = { projection: "EPSG:4326"} è¿ä¸ªé
ç½®æ¯éè¦çè¦ä¸ç¶ ï¼å¾å±ä¼æ·»å 失败ã
3.对äºconfigé
ç½®ç项è¦æ³¨æçå°æ¹ï¼LAYERSå±æ§æ¯ä½ åå¸çæå¡çå¾å±å称
FORMAT ï¼"image/png" è¿ä¸ªå±æ§ä¹è¦æ³¨æï¼å½æ¶æåçæ¯image/jpeg,åºç°äºé®é¢ï¼æ¹ä¸ºpngå°±æ£å¸¸äº
ä»¥ä¸ æ³¨æäºï¼åºè¯¥å°±ä¸ä¼æé®é¢äºã