示例描述

该示例展示如何设置地图背景,使用backgroundColor设置背景填充色,使用backgroundImage设置背景填充图片,backgroundImageMode为图片填充模式,包括拉伸“scale”、平铺“repeat”、剪裁“clip”。

效果演示

示例代码

<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <script src='http://dev.dituhui.com/sdk/1.0.0/js/dituhui-flash.js'></script>
  <script src='http://dev.dituhui.com/sdk/1.0.0/js/sample-data.js'></script>
  <script type="text/javascript">
   var map = null;
   function init(){
    map = new Dituhui.Map("myMap", "http://dev.dituhui.com/sdk/1.0.0/swfs/", "100000", Dituhui.MapType.RANGE, "setData", "onError");
   }
   function setData()
   {
    var mapStyles = [
    {min:1,max:4},
    {min:4,max:8},
    {min:8,max:12},
    {min:12,max:16}];

    var option = 
    {
     data: data, 
     styles:mapStyles, 
     fillColorType:"red",
     valueField:'gdprate',
     legendTitle:"GDP增速%",
     /*设置地图背景填充色*/
     backgroundColor:"#F5F5F5",
     /*设置背景填充图片*/
     backgroundImage:"http://dev.dituhui.com/assets/img/bgImage.png",
     /*设置图片填充模式,包括:拉伸“scale”,
     平铺“repeat”,剪裁“clip”*/
     backgroundImageMode:"repeat"
    };
    map.setMapOptions(option);
   }
   function onError(errorcode)
   {
    /*errorcode:错误编码,有关错误编码的详细描述可参考:
    "开发指南"-->"API参考"-->"错误编码"*/
    alert(errorcode);          
   }
   window.onload = init;
  </script>
 </head>
 <body>
  <div id='myMap' style='width:660px;height:600px'>
  </div>
 </body>
</html>