【问题标题】:Setting the map by Divin size?按 Divin 大小设置地图?
【发布时间】:2018-09-25 04:10:15
【问题描述】:

我无法更改https://codepen.io/sinanelms/pen/MqdNNY 的代码大小。您想帮助地图根据屏幕的大小进行放大和缩小吗?

我从事以下工作,但无法做到我想要的。

<style type="text/css">
   body{
   background:#fff;}
   #map{
   width:1050px;
   height:620px;
   position:relative;}
   #map svg {
   position: relative;top:
   -100px; 
   left: 0px;}
   svg > a {cursor: pointer;display:block;}
   #sehir{font-size:30px;text-align:center;margin-top:25px;color:#666;}
</style>
<div>
</div>
<div id="sehir"></div>
<div id="map"></div>

【问题讨论】:

    标签: python html flask-sqlalchemy


    【解决方案1】:

    使用 Jquery 窗口调整大小来设置 widthheightsetViewBoxsetSize。使用 window resize 查看下面的代码。

    JS

    var w = 1000, h=500;
    var r = Raphael('map', w, h),
    attributes = {
        fill: '#666',
        stroke: '#fff',
        'stroke-width':.5,
        'stroke-linejoin': 'round',
    },
    
    arr = new Array();
    
    r.setViewBox(10, 100, w,h,true);
    r.setSize('100%', '100%');
    
    $(window).resize(function(){
        r.setViewBox(10,100,w,h,true);
        r.setSize('100%', '100%');
    });
    

    CSS

    #map {
      position: relative;
      border: 1px solid red;
    }
    
    #map svg {
      position: relative;
    }
    
    svg>a {
      cursor: pointer;
      display: block;
    }
    

    【讨论】:

    • 我不会说英语 :) 我正在用谷歌翻译进行翻译,对荒谬的翻译感到抱歉 :) @ShivKumarBaghel
    • 我有一个小问题,根据一个随机的ID我想画那个地方,我没有做以下。代码在这里。 codepen.io/sinanelms/pen/MqdNNY?editors=1010//random selected function random(){ var ran=Math.floor(Math.random() * 82); if(obj.id==ran){obj.animate({fill: '#000'}, 200); } } setInterval(function(){random();}, 1000); //random end
    【解决方案2】:

    当您使用 id map 发起 Raphael 时,传递 width in %。 下面用width 100%height 800px发起。

    var r = Raphael('map', '100%', '800'),

    还使用#map从内联css中删除widthheight

    #map{
       width:1050px;
       height:620px;
       position:relative;
    }
    

    【讨论】:

    • 我已更新 r = Raphael ('map', '100%', '800') 。我使用#map 从内联 css 中删除了宽度和高度,但它仍然没有按我的意愿发生。我希望缩小window.var r = Raphael('map', '100%', '800') 时地图缩小,当800为300时,地图的一半可见。
    猜你喜欢
    • 2016-09-13
    • 2011-06-13
    • 1970-01-01
    • 2018-05-08
    • 2011-07-08
    • 1970-01-01
    • 2015-10-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多