2 fenglinstudio fenglinstudio 于 2016.04.22 20:41 提问

有没有什么好的JavaScript地图控件可以实现根据数据量变色、链接等,另外需要修改脚本一则
 <script type="text/javascript">
$(function(){
    var data = {"jiangsu":{"value":"<{$count5}>","stateInitColor":"4"},"heilongjiang":{"value":"<{$count4}>","stateInitColor":"3"},"henan":{"value":"<{$count2}>","stateInitColor":"0"},"anhui":{"value":"<{$count3}>","stateInitColor":"3"},"zhejiang":{"value":"<{$count9}>","stateInitColor":"4"},"beijing":{"value":"<{$count1}>","stateInitColor":"4"},"sichuan":{"value":"<{$count6}>","stateInitColor":"6"},"fujian":{"value":"<{$count8}>","stateInitColor":"5"},"gansu":{"value":"<{$count7}>","stateInitColor":"3"},"macau":{"value":"未知","stateInitColor":"7"},"hongkong":{"value":"未知","stateInitColor":"7"},"taiwan":{"value":"未知","stateInitColor":"7"},"xizang":{"value":"未知","stateInitColor":"7"}};
            var i = 1;
            for(k in data){
                if(i <= 12){
                    var _cls = i < 4 ? 'active' : ''; 
                    $('#MapControl .list1').append('<li name="'+k+'"><div class="mapInfo"><i class="'+_cls+'">'+(i++)+'</i><span>'+chinaMapConfig.names[k]+'</span><b>'+data[k].value+'</b></div></li>')
                }else if(i <= 24){
                    $('#MapControl .list2').append('<li name="'+k+'"><div class="mapInfo"><i>'+(i++)+'</i><span>'+chinaMapConfig.names[k]+'</span><b>'+data[k].value+'</b></div></li>')
                }else{
                    $('#MapControl .list3').append('<li name="'+k+'"><div class="mapInfo"><i>'+(i++)+'</i><span>'+chinaMapConfig.names[k]+'</span><b>'+data[k].value+'</b></div></li>')
                }
            }

            var mapObj_1 = {};
            var stateColorList = ['990a00', 'bf0c00', 'ee0e00', 'ff362a', 'ff7c74', 'ffd3d0', '#ffe4e1', 'ffffff'];

            $('#RegionMap').SVGMap({
                external: mapObj_1,
                mapName: 'china',
                mapWidth: 600,
                mapHeight: 510,
                stateData: data,
                // stateTipWidth: 118,
                // stateTipHeight: 47,
                // stateTipX: 2,
                // stateTipY: 0,
                stateTipHtml: function (mapData, obj) {
                    var _value = mapData[obj.id].value;
                    var _idx = mapData[obj.id].value;
                    var active = '';
                    _idx < 4 ? active = 'active' : active = '';
                    var tipStr = '<div class="mapInfo"><span>' + obj.name + '</span><b>' + _value + '</b></div>';
                    return tipStr;
                }
            });
            $('#MapControl li').hover(function () {
                var thisName = $(this).attr('name');

                var thisHtml = $(this).html();
                $('#MapControl li').removeClass('select');
                $(this).addClass('select');
                $(document.body).append('<div id="StateTip"></div');
                $('#StateTip').css({
                    left: $(mapObj_1[thisName].node).offset().left - 50,
                    top: $(mapObj_1[thisName].node).offset().top - 40
                }).html(thisHtml).show();
                mapObj_1[thisName].attr({
                    fill: '#E99A4D'
                });
            }, function () {
                var thisName = $(this).attr('name');

                $('#StateTip').remove();
                $('#MapControl li').removeClass('select');
                mapObj_1[$(this).attr('name')].attr({
                    fill: "#" + stateColorList[data[$(this).attr('name')].stateInitColor]
                });
            });

            $('#MapColor').show();
    //  }
    // });


    $('#WorldMap').SVGMap({
        mapName: 'world',
        mapWidth: 600,
        mapHeight: 400
    });
});
</script>

上面是个地图脚本,jiangsu":{"value":"<{$count5}>","stateInitColor":"4"}这是指江苏省的计数和变色,现在的色是4,希望修改成数据量超过1000的省份在这里显示6,数据量超过2千的显示5,跪求!

1个回答

devmiao
devmiao   Ds   Rxr 2016.04.23 06:28
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!