示例描述

该示例展示用户自定义填充样式,用户可为每一分段自定义填充颜色、填充透明度、边界样式等,更多接口说明请参考地图样式设置

效果演示

示例代码

<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()
   {
    /*将数据分为5组,为每一组分别赋予不同的颜色*/
    var mapStyles = [
    {min:1,max:3,fillColor:'#377EB8'},
    {min:3,max:6,fillColor:'#984EA3'},
    {min:6,max:9,fillColor:'#FFFF33'},
    {min:9,max:12,fillColor:'#A65628'},
    {min:12,max:15,fillColor:'#F781BF'}];
    var option = 
    {
     data: data, 
     styles:mapStyles, 
     valueField:'gdprate',
     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:660px;height:600px'>
  </div>
 </body>
</html>