2014-10-30 6 views
0

gmap3에 문제가 있습니다. 마커에 정보를 추가하고 정보 창에 정보를 표시하고 싶습니다. 그러나 기본 마커는 "제목", "데이터"및 일부 옵션과 같은 일부 변수 만 포함하므로이 정보를 마커에 추가하는 방법을 모르겠습니다.Gmap3 마커에 몇 가지 새로운 변수를 추가하고 마우스 이벤트가 발생하면 검색하는 방법은 무엇입니까?

이제 주소와 같은 정보를 추가하고 싶습니다. 마커에 이벤트를 저장하고 마우스 이벤트가 발생하면 어떻게 가져 옵니까?

$('#gmap').gmap3({ 
     map:{ 
      options:{ 
       center:[10.823099,106.629664], 
       zoom: 15 
      } 
     }, 
     marker:{ 
      values:Markers, 
      options:{ 
       draggable: false 
      }, 
      events:{ 
       click: function(marker,event,context){ 

       }, 
       mouseover: function(marker, event, context){ 
        var map = $(this).gmap3("get"), 
          infowindow = $(this).gmap3({get:{name:"infowindow"}}); 

        if (infowindow){ 
         infowindow.open(map, marker); 
         infowindow.setContent('<div class="infoWindow">'+context.data+'</div>'); 
        } else { 
         $(this).gmap3({ 
          infowindow:{ 
           anchor:marker, 
           options:{content: context.data} 
          } 
         }); 
        } 
       }, 
       mouseout: function(){ 
        var infowindow = $(this).gmap3({get:{name:"infowindow"}}); 
        if (infowindow){ 
         infowindow.close(); 
        } 
       } 
      } 
     } 

    }); 

여기 내 초기화 기능입니다.

는 그리고 이것은 내 마커입니다 :

marker = { 
      latLng : [location.Latitude, location.Longitude], 
      data : '<span class="title"><b>'+location.Title+'</b></span>'+'<br>'+'<span class="address">'+location.Address+'</span>', 
      options:{icon: 'data:image/png;base64,'+location.LocationType.Image}, 
      locationData: location 
     }; 
     Markers.push(marker); 

그래서 메인 질문 : 어떻게 locationData 때 클릭 이벤트 화재를 검색 할 수 있습니까?

미리 감사드립니다.

답변

0

나는 해결책을 스스로 발견했다.

첫 번째는 gmap3.js로 이동하여 기능 편집 : 내가 키에 locationData를 추가해야

function tuple(args, value) { 
    var k, i, 
     keys = ["data", "tag", "id", "events", "onces", "locationData"], 
     td = {}; 

참고.

그런 다음 기원의 js 파일을 편집해야이

function attachEvents($container, args, sender, id, senders) { 
    var td = args.td || {}, 
     context = { 
      id: id, 
      data: td.data, 
      tag: td.tag, 
      locationData: td.locationData 
     }; 

이 방법처럼 이벤트 및 편집을 첨부 기능으로 이동합니다. 더 나은 솔루션을 찾고 있습니다. 감사합니다.