2012-10-05 51 views
0
  1. 。我對raphael.js.非常新,我用t.I可以改變顏色,而mouseover.But我做了一個歐洲地圖,但我只想放大 特定的國家,而ts點擊。它必須像放大t
    點擊國家與一些特定點的n個國家放大n分裂國家n raphael.js

    script type="text/javascript" charset="utf-8"> 
          $(document).ready(function() { 
          var rsr = Raphael('map', '631', '686'); 
          var attr = { 
             fill: "#C0C0C0", 
             stroke: "#666", 
             "stroke-width": 1, 
             "stroke-linejoin": "round" 
            }; 
           var world = {}; 
           world.Portugal = rsr.path("56,0.133-1.32,0.527c-0.661,1.321-0.264,2.906-0.925,4.228c-0.528,1.057-3.698,5.415-3.434,6.868 
    c0.132,0.526,1.056-0.529,1.584-0.529c0.792-0.132,1.585,0.133,2.377,0c0.396,0,0.792-0.396,1.188-0.264 
    c2.113,0.527,8.981,5.019,9.906,4.887c0.396,0,4.49-1.981,4.754-2.113C57.876,621.536,58.537,621.536,59.197,621.536L59.197,621.536 
    z").attr(attr);; 
           world.Spain = rsr.path(" M194.57,552.728c0.924,0.396,1.981,0.63.434,4.754c-,0,0.792,0  
    c0.661,0.133,1.453,0.133,1.849,0.528c0.66,0.528,0.264,1.717,0.924,2.113v0.132C190.74,552.066,190.476,553.916,194.57,552.728 
    L194.57,552.728z").attr(attr); 
         var current = null; 
           for(var country in world) { 
           (function (st, country) { 
            country = country.toLowerCase(); 
            st[0].style.cursor = "pointer"; 
            st[0].onmouseover = function() { 
             st.animate({fill:"#808080", stroke: "#ccc"}, 500); 
            }; 
            st[0].onmouseout = function() { 
             st.animate({fill: "#C0C0C0", stroke: "#666"}, 500); 
             st.toFront(); 
             R.safari(); 
            }; 
            st[0].onclick = function() { 
             st.animate({width: "500px"}, 'slow');//THS DOES NOT WORk 
            }; 
           })(world[country], country); 
           } 
          });  
    

    誰能幫助我該怎麼辦???部份請

    .. 
    
+1

請重新格式化您的問題 - 無法閱讀其當前狀態 – boz

+0

我建議您製作一個http://jsfiddle.net/,否則,描述您嘗試實現什麼行爲,如何做到這一點和什麼是錯的。 – Qnan

+0

@boz它是可讀的,實際上,只是非常不愉快的閱讀。答案是OP正試圖設置路徑實際上不具備的'寬度'屬性。正確的方法是設置'transform'屬性。 – Qnan

回答

0

您正在嘗試設置「寬」屬性事實上,這條道路實際上就是這樣不具備。要走的路是將'transform'屬性設置爲here。您可能還必須設置縮放原點,因爲您縮放的路徑不是居中於零(參見Raphael center of scale in transform method)。

+0

許多Thans爲您的答覆。我應該如何使用地圖上的變換。請解釋我一下我對raphaeel很新。 – Indira

+0

檢查http://stackoverflow.com/questions/9867975/raphael-center-of-scale-in-transform-method,有一個例子。 – Qnan

+0

Thans很多Qnan爲你的努力。但嘗試像ST [0] .onclick = function(){ \t st.transform(「s0.500」) };它不工作.. – Indira