2017-01-17 6 views
1

에 대한 사용자 정의 마커 클릭에 기능화재 자바 스크립트 내가 (그냥 예처럼 : <a href="https://www.amcharts.com/demos/custom-html-elements-map-markers/" rel="nofollow noreferrer">https://www.amcharts.com/demos/custom-html-elements-map-markers/</a>) 사용자 정의 HTML 마커가있는 AmChart 세계지도 활용하기 위해 노력하고있어 AmCharts

내가 가진 코드는 다음과 같습니다과 내가 추가 한 것 AmChart 웹 사이트의 또 다른 예를 기반으로 한 유효한 클릭 수신기가되기를 바랍니다.

var map; 
map = AmCharts.makeChart("chartdiv", { 
    "type": "map", 
    "theme": "black", 
    "projection": "miller", 

    "imagesSettings": { 
    "rollOverColor": "#42adca", 
    "rollOverScale": 3, 
    "selectedScale": 3, 
    "selectedColor": "#42adca", 
    "color": "#42adca" 
    }, 

    "areasSettings": { 
    "unlistedAreasColor": "#42adca" 
    }, 

    "dataProvider": { 
    "map": "worldLow", 
    "images": [ { 
     "zoomLevel": 5, 
     "scale": 0.5, 
     "title": "San Jose, CA", 
     "latitude": 37.3382, 
     "longitude": -121.8863, 
     "click": 'test()' 
    }, { 
     "zoomLevel": 5, 
     "scale": 0.5, 
     "title": "Dulles, VA", 
     "latitude": 38.9559, 
     "longitude": -77.4478 
    }, { 
     "zoomLevel": 5, 
     "scale": 0.5, 
     "title": "London, UK", 
     "latitude": 51.5074, 
     "longitude": 0.1278 
    }, { 
     "zoomLevel": 5, 
     "scale": 0.5, 
     "title": "Denver, CO", 
     "latitude": 39.7392, 
     "longitude": -104.9903 
    }, { 
     "zoomLevel": 5, 
     "scale": 0.5, 
     "title": "Miami, FL", 
     "latitude": 25.7617, 
     "longitude": -80.1918 
    }, { 
     "zoomLevel": 5, 
     "scale": 0.5, 
     "title": "Los Angeles, CA", 
     "latitude": 34.0522, 
     "longitude": -118.2437 
    }, { 
     "zoomLevel": 5, 
     "scale": 0.5, 
     "title": "New York, NY", 
     "latitude": 40.7128, 
     "longitude": -74.0059 
    }, { 
     "zoomLevel": 5, 
     "scale": 0.5, 
     "title": "Chicago, IL", 
     "latitude": 41.8781, 
     "longitude": -87.6298 
    } ] 
    }, 
    "listeners": [{ 
    "event": "clickMapObject", 
    "method": function(event) { 
     console.log(event.mapObject.title); 
    } 
    }] 
}); 

그러나 console.log는 실행되지 않습니다. 지도를 클릭해도 아무런 변화가 없습니다. URL을 설정할 수는 있지만 JS 함수를 지정하려고합니다.

모든 포인터가 좋을 것입니다.

답변

1

게시 한 직후 나는 대답을 찾았습니다.

'URL'매개 변수는 일반 HREF 같은 역할을하므로,이 유효합니다

"dataProvider": { 
    "map": "worldLow", 
    "images": [ { 
     "zoomLevel": 5, 
     "scale": 0.5, 
     "title": "San Jose, CA", 
     "latitude": 37.3382, 
     "longitude": -121.8863, 
     "url": 'javascript:test()' 
    }, { 
     "zoomLevel": 5, 
     "scale": 0.5, 
     "title": "Dulles, VA", 
     "latitude": 38.9559, 
     "longitude": -77.4478 
    }, { 

"URL을" '자바 스크립트 : 테스트()'