2014-06-06 4 views
-3

지도 좌표를 사용하여 이미지 맵을 만들었으므로 잘 작동하지만 강조 표시가 필요하지만 강조 표시 색상을 변경하려면 조건에 따라 다릅니다. ... 첫 번째 condtion에서 붉은 색 영역을 강조 표시 한 다음 동일한 영역이 두 번째 조건에 대한 검은 색으로 강조 표시됩니다. 동일한 영역을 강조 표시 할 수 있지만 동시에 영역 색상을 변경할 수 없습니다. 여기에 바이올린에JQuery maphighlight는 조건에 따라 영역 강조 색상을 변경합니다.

내 샘플 코드 : Fiddle Demo

내가

<script> 
     $(document).ready(function() //on page load 
     { 
      $('area[title*="UPPER"]').each(function()//get all areas 
      { 
       $(this).addClass("victory"); 
      }); 

      $('area[title*="LOWER"]').each(function()//get all areas 
      { 
       $(this).addClass("lose"); 
      }); 

      //initialize highlight 
      $('.map').maphilight({ strokeWidth: 0, fillColor: "0000FF", fillOpacity: 0.8, singleSelect: true }); 

      ////map wrap 
      $(".victory").click(function() {     
       //This block is what creates highlighting by trigger the "alwaysOn", 
       var data = $(this).data('maphilight') || {}; 
       data.alwaysOn = !data.alwaysOn; 
       $(this).data('maphilight', data).trigger('alwaysOn.maphilight'); 
       //there is also "neverOn" in the docs, but not sure how to get it to work 
      }); 

      $('.map').maphilight({ strokeWidth: 0, fillColor: "FFFF00", fillOpacity: 0.8}); 

      $(".lose").click(function() {     
       //This block is what creates highlighting by trigger the "alwaysOn", 
       var data = $(this).data('maphilight') || {}; 
       data.alwaysOn = !data.alwaysOn; 
       $(this).data('maphilight', data).trigger('alwaysOn.maphilight'); 
       //there is also "neverOn" in the docs, but not sure how to get it to work 
      }); 
     }); 
    </script> 

Fiddle Demo

하지만 두 번째 fillcolor.any 하나의 도움으로 첫하고 fillColor을 덮어이다 사용하여 시도했다 이 문제를 해결하려면 area.style하지 background-color 속성을 가지고 있기 때문에

+0

같은 좌표로 캔버스를 오버레이합니다 ... –

+0

@ Mr.Alien 얻을 수 없습니다. –

+0

을 설명 할 수 있습니까? http://jsfiddle.net/tZKuv/3/을 확인하십시오. 플러그인 워드 프로세서를 사용하지 않을 것입니다.하지만이 옵션을 사용하게 될 것이라고 생각합니다. –

답변

2

귀하의 코드가 작동하지 않습니다 확인. 또한 titlearea 초로 설정하지 않았다면 대신 alt 초가있는 것 같습니다.

사용 된 plug-in은 이미지에 지나치게 캔버스 요소를 만들고 강조 색상은 그 캔버스의 부분적으로 투명하지 않은 부분임을 유의하십시오. 지도의 특정 부분을 노란색으로 표시하려면 이미지 자체를 변경하거나 나중에 숨길 수있는 예를 들어 오버레이 된 이미지를 사용해야합니다. 와 어쨌든

, 플러그인이 같은 작업을 수행 할 수 있습니다

$(function() { 
    var data = {}; 
    $('.map').maphilight(); 
    data.alwaysOn = true; 
    data.fillColor = 'ffff00'; 
    data.fillOpacity = '0.6'; 
    $('area[alt="UPPER HANOVER TOWNSHIP"]').data('maphilight', data).trigger('alwaysOn.maphilight'); 
}); 

A live demo at jsFiddle.

+0

생각해 주셔서 감사합니다. 나는 당신의 솔루션을 생각 해냈다 .. http://jsfiddle.net/X4mPW/6/ –

0

작업 코드는 다음과 같습니다,이

 $(document).ready(function() //on page load 
{ 
    $('area').each(function()//get all areas 
       { 
        var co=$(this).attr('coords');//get coords by attr from area 
        alert(co); //alert coords in alertbox 
       }); 
}); 
+0

어떤 색상으로 특정 좌표를 강조하고 싶다 .... 경고하지 않는다 –

+0

코드가 호버 기능을 위해 작동한다. 단지 호버 기능을 제거한다. .... 그리고 오직 준비 기능을 사용하고 코드를 작성하십시오. $ (document) .ready (function() // 페이지로드 { // 여기에 작업 코드 }); –

+0

질문을 명확하게 읽으십시오. 내 문제는 –