示例描述

用户数据格式中,表达行政区名的列支持以下三种方式。下面示例使用北京市各区的6位行政区码(regionFeild:'code_6')生成地图。

效果演示

示例代码

<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/", "110000", Dituhui.MapType.RANGE, "setData", "onError");
   }
   function setData()
   {
    var mapStyles = [
     {min:0,max:352},
     {min:352,max:433},
     {min:433,max:600},
     {min:600,max:1000,includeMax:true}];

    var option = 
    {
     data:[{name:'朝阳',code_6:'110105',code_12:'110105000000',gdp:'1000'},
       {name:'海淀',code_6:'110108',code_12:'110108000000',gdp:'300'},
       {name:'东城',code_6:'110101',code_12:'110101000000',gdp:'600'},
       {name:'西城',code_6:'110102',code_12:'110102000000',gdp:'400'},
       {name:'顺义',code_6:'110113',code_12:'110113000000',gdp:'256'},
       {name:'怀柔',code_6:'110116',code_12:'110116000000',gdp:'654'},
       {name:'丰台',code_6:'110106',code_12:'110106000000',gdp:'345'},
       {name:'石景山',code_6:'110107',code_12:'110107000000',gdp:'743'},
       {name:'昌平',code_6:'110114',code_12:'110114000000',gdp:'536'},
       {name:'通州',code_6:'110112',code_12:'110112000000',gdp:'433'},
       {name:'平谷',code_6:'110117',code_12:'110117000000',gdp:'256'},
       {name:'密云',code_6:'110228',code_12:'110228000000',gdp:'753'},
       {name:'房山',code_6:'110111',code_12:'110111000000',gdp:'472'},
       {name:'大兴',code_6:'110115',code_12:'110115000000',gdp:'256'},
       {name:'延庆',code_6:'110229',code_12:'110229000000',gdp:'352'},
       {name:'门头沟',code_6:'110109',code_12:'110109000000',gdp:'356'}],
     styles:mapStyles, 
     valueField:'gdp',
     /*使用6位行政区代码*/
     regionFeild:'code_6',
     isRLabelVisible:true,
     showRegionField:'name',
     backgroundColor:"#F5F5F5",
     legendTitle:"北京GDP(万元)"
    };
    map.setMapOptions(option);
   }
   function onError(errorcode)
   {
    /*errorcode:错误编码,有关错误编码的详细描述可参考:
    "开发指南"-->"API参考"-->"错误编码"*/
    alert(errorcode);          
   }
   window.onload = init;
  </script>
 </head>
 <body>
  <div id='myMap' style='width:680px;height:500px'>
  </div>
 </body>
</html>