var MyCustomMarker = L.Marker.extend({ bindPopup: function(htmlContent, options) { if (options && options.showOnMouseOver) { // call the super method L.Marker.prototype.bindPopup.apply(this, [htmlContent, options]); // click event to open url this.on('click', function(){ window.location = (this.url); }); // bind to mouse over this.on("mouseover", function(e) { // get the element that the mouse hovered onto var target = e.originalEvent.fromElement || e.originalEvent.relatedTarget; var parent = this._getParent(target, "leaflet-popup"); // check to see if the element is a popup, and if it is this marker's popup if (parent == this._popup._container) return true; // show the popup this.openPopup(); }, this); // and mouse out this.on("mouseout", function(e) { // get the element that the mouse hovered onto var target = e.originalEvent.toElement || e.originalEvent.relatedTarget; // check to see if the element is a popup if (this._getParent(target, "leaflet-popup")) { L.DomEvent.on(this._popup._container, "mouseout", this._popupMouseOut, this); return true; } // hide the popup this.closePopup(); }, this); } }, _popupMouseOut: function(e) { // detach the event L.DomEvent.off(this._popup, "mouseout", this._popupMouseOut, this); // get the element that the mouse hovered onto var target = e.toElement || e.relatedTarget; // check to see if the element is a popup if (this._getParent(target, "leaflet-popup")) return true; // check to see if the marker was hovered back onto if (target == this._icon) return true; // hide the popup this.closePopup(); }, _getParent: function(element, className) { var parent = element.parentNode; while (parent != null) { if (parent.className && L.DomUtil.hasClass(parent, className)) return parent; parent = parent.parentNode; } return false; } }); function setRegion(id) { switch (id) { case 1: map.flyTo([49, -105], 2); // North + Meso America ajaxFunction("main_navi", "dobes_project_links/index.php?region=1"); break; case 2: map.flyTo([-15, -61], 3); // South America ajaxFunction("main_navi", "dobes_project_links/index.php?region=2"); break; case 3: map.flyTo([48, 72], 2); // Eurasia ajaxFunction("main_navi", "dobes_project_links/index.php?region=3"); break; case 4: map.flyTo([-4, 15], 3); // Africa ajaxFunction("main_navi", "dobes_project_links/index.php?region=4"); break; case 5: map.flyTo([-3, 160], 3); // Oceania ajaxFunction("main_navi", "dobes_project_links/index.php?region=5"); break; } } var markers = new L.FeatureGroup(); var dobesIcon = L.icon({ iconUrl: '/wp-content/themes/dobes/js/../images/dobes_marker.png', iconSize: [16, 16], popupAnchor: [1, 0] }); var projects = [["\u2260Akhoe Hai\/\/om","akhoe","1839\/00-0000-0000-0004-DDF2-2",4,16.50835277777778,-17.81203055555556],["Ach\u00e9","ache","1839\/00-0000-0000-0014-C52F-7",2,-55.64114953673442,-24.12684335966327],["Southeastern Rond\u00f4nia","southeastern_rondonia","1839\/00-0000-0000-0019-E76D-1",2,-60.41380000194953,-12.65100000012067],["Akie","akie","1839\/f6f9a96e-e3c2-4b62-bf40-4c11c8d17448",4,36.0881222162923,-5.47766515256113],["West Ambrym","ambrym","1839\/00-0000-0000-000E-1808-8",5,167.9403407703047,-16.24456537547754],["Awet\u00ed","aweti","1839\/00-0000-0000-0001-305C-A",2,-53.39154162761788,-12.38292390527443],["Ba\u00efnounk","bainounk","1839\/00-0000-0000-0016-3656-0",4,-16.33120899773539,12.74182599667788],["Bagyeli\/Bakola","bakola","1839\/00-0000-0000-0014-C529-A",4,10.73333299856731,3.233332999664737],["Baure","baure","1839\/00-0000-0000-000D-8382-B",2,-63.69347787830142,-13.65482487898197],["Bayso\/Haro","bayso_haro","1839\/00-0000-0000-0017-F327-0",4,37.75000000046403,6.249999998585252],["Beaver","beaver","1839\/00-0000-0000-0001-34B1-5",1,-120.482782682017,56.61658355313985],["Bena Bena","benabena","1839\/00-0000-0000-0016-B159-5",5,145.537003,-6.11391],["Bezen","bezen","1839\/290cc46b-23f6-473f-81c9-87762ec145ff",4,10.06783210787575,6.752494252527146],["Cashinahua","cashinahua","1839\/00-0000-0000-0008-4070-6",2,-71.57545183215336,-10.42969693460424],["CELD Papua","celd","1839\/00-0000-0000-0017-E884-A",5,139.3351891625389,-4.199547491533352],["Chaco Languages","chaco","1839\/00-0000-0000-0001-34DE-7",2,-60.20724815637318,-26.80857643736235],["Chintang\/Puma","chintang","1839\/00-0000-0000-0005-24BD-D",3,87.01590016489011,26.98846005604396],["Chipaya","chipaya","1839\/00-0000-0000-0008-24CA-F",2,-68.08953842109413,-19.04158671057432],["Chontal","chontal","1839\/00-0000-0000-0005-831C-C",1,-95.70887044186784,15.98570734159531],["D\u00e9l\u0131\u0328n\u0119","deline","1839\/00-0000-0000-0019-EE0F-7",1,-123.4227519831766,65.18885100162355],["\u0116ven","even","1839\/00-0000-0000-000F-2DFE-0",3,131.8635510406172,65.02385626216146],["Gorani","gorani","1839\/00-0000-0000-0009-E89B-9",3,46.30267965689424,34.92057478243947],["Hooc\u0105k","hocank","1839\/00-0000-0000-0001-367F-7",1,-90.83967777777778,44.28661944444444],["Isubu\/Wovia","isubu_wovia",1384636,4,9.195443000322092,4.022465998111797],["Iwaidja","iwaidja","1839\/00-0000-0000-0001-3709-6",5,132.5779579640883,-11.14851401426966],["Jaminjungan and Eastern Ngumpin","jaminjung","1839\/00-0000-0000-0004-DF7A-E",5,130.3803472222222,-15.52368888888889],["Khinalug","khinalug","1839\/00-0000-0000-0016-2EB3-C",3,48.12769337846439,41.17868975440174],["Kola S\u00e1mi","sami","1839\/00-0000-0000-0005-8A34-E",3,35.01602688922696,68.00636055775709],["Kuikuro","kuikuro","1839\/00-0000-0000-0001-379E-4",2,-53.20926628408038,-12.35175773182949],["Kurumba Languages","kurumba","1839\/00-0000-0000-000D-8383-9",3,76.4863868554639,11.59016758447595],["Kyanga\/Shanga","kyanga_shanga","1839\/00-0000-0000-0017-CFE8-5",4,4.579210284948916,11.21313850059646],["Laal","laal","1839\/00-0000-0000-0017-B129-C",4,17.66666666659567,9.999999999606025],["Lacandon","lacandon","1839\/00-0000-0000-0001-390B-C",1,-91.58267107396529,16.97845623372331],["Lakota","lakota",0,1,-101.8333333344463,43.83333333361865],["Lower Sorbian","lower_sorbian","1839\/00-0000-0000-0016-9194-2",3,14.334167,51.760556],["Marquesan","marquesan","1839_00_0000_0000_0001_3B2D_1",5,220.0600534745392,-9.377482662553186],["MEL project \/ Tuamotuan","tuamotuan","1839\/00-0000-0000-000D-B80D-8",5,220.6656047146723,-18.42074942288098],["Minderico","minderico","1839\/00-0000-0000-000F-2DFF-A",3,-8.689602000269023,39.51384900015493],["Morehead (Nen\/K\u00f3mnzo)","morehead","1839\/00-0000-0000-0017-89A2-B",5,141.9917199750585,-8.5846993738285],["Movima","movima","1839\/00-0000-0000-0007-DDFD-4",2,-65.42190000000001,-13.74117222222222],["Nenets","nenets","1839\/00-0000-0000-0008-2194-0",3,81.88368627273296,66.69712337471037],["Nsambaan\/Nsong\/Ngong","nsambaan_nsong_ngong","1839\/00-0000-0000-001A-9F2B-A",4,18.81625722928512,-5.041063465204402],["Oyda","oyda","1839\/00-0000-0000-0016-3694-8",4,36.65029999738834,5.943800001638671],["People of the Center","center","1839\/00-0000-0000-0005-802E-9",2,-72.54564450105971,-2.509479906359513],["Salar\/Monguor","salar","1839\/00-0000-0000-0001-3DA3-5",3,101.7897095744772,36.00236439389911],["Saliba\/Logea","saliba","1839\/00-0000-0000-0008-1484-1",5,152.6016944444444,-10.645175],["Savosavo","savosavo","1839\/00-0000-0000-0008-7347-A",5,159.8384750583851,-9.126841764954664],["Semang","semang","1839\/00-0000-0000-0008-719D-6",5,101.1557192935373,5.415886959145203],["Semaq Beri\/Batek","semaq_beri_batek","1839\/00-0000-0000-000A-2119-E",5,102.3666700000001,3.9333334],["Shiri\/Sanzhi","shiri_sanzhi","1839\/00-0000-0000-0018-A4D4-6",3,47.40872572217202,42.26668506985605],["Sri Lanka Malay","slm","1839\/00-0000-0000-0007-DDFE-2",3,79.89667155892515,6.900104246292309],["Svan\/Udi\/Tsova-Tush","svan","1839\/00-0000-0000-0008-24AD-F",3,42.73019722222222,43.04572222222222],["Taa","taa","1839\/00-0000-0000-0004-DDF3-4",4,20.00365555555556,-23.16853888888889],["Tangsa\/Tai\/Singpho","singpho_tai_tangsa","1839\/00-0000-0000-000D-BB1A-A",3,95.65894100378183,27.2973489994279],["Teop","teop","1839\/00-0000-0000-0001-3DB8-C",5,155.074625,-5.577897222222222],["Tima","tima","1839\/00-0000-0000-0008-2195-8",4,29.25392663770311,11.72143375034394],["Tofa","tofa","1839\/00-0000-0000-0001-3F6C-E",3,98.23504999999999,53.69414999999999],["Totoli","totoli","1839\/00-0000-0000-0005-24BE-F",5,120.8163138888889,1.042961111111111],["Trumai","trumai","1839\/00-0000-0000-0008-3A0E-7",2,-53.59444202212001,-11.85721413118175],["Tsafiki","tsafiki","1839\/00-0000-0000-0001-46BA-3",2,-79.15190370112373,-0.1869792123556514],["Ujir","ujir","1839\/00-0000-0000-001C-903D-9",5,134.2772974144609,-5.612607464105282],["Uru-Chipaya","uru-chipaya","1839\/00-0000-0000-0009-FD76-B",2,-68.08953842109413,-19.04158671057432],["Vur\u00ebs\/Vera’a","vures_veraa","1839\/00-0000-0000-0009-E89C-6",5,167.4800777777778,-13.76311388888889],["Waima’a","waimaa","1839\/00-0000-0000-0001-473A-3",5,126.4503032431727,-8.464103646239048],["Wichita","wichita","1839\/00-0000-0000-0001-483D-C",1,-98.22831111111113,35.06406388888889],["Wooi","wooi","1839\/00-0000-0000-0014-C76C-1",5,135.5076944444444,-1.679472222222222],["Yurakar\u00e9","yurakare","1839\/00-0000-0000-0008-2196-6",2,-65.16372371856787,-16.00321576899253]]; // specify popup options var popupOptions = { 'maxWidth': '500', 'className' : 'custom-popup', showOnMouseOver: true } var mapLink = 'OpenStreetMap'; var dobesmap = L.tileLayer( 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© ' + mapLink + ' Contributors', maxZoom: 18, }); var map = L.map('map') .setView([20, 40], 1) .addLayer(dobesmap); var marker_array = []; function populate() { for (var i = 0; i < projects.length; i++) { var marker = new MyCustomMarker([projects[i][5],projects[i][4]], {icon: dobesIcon, myId: i}); marker.bindPopup(projects[i][0], popupOptions); marker.url = 'https://dobes.mpi.nl/projects/' + projects[i][1]; marker_array[i] = marker; markers.addLayer(marker); } return false; } map.addLayer(markers); populate(); function highlightMarker(i) { current = marker_array[i]; current.openPopup(); } function normaliseMarker(i) { current = marker_array[i]; current.closePopup(); } /* AJAX function from http://www.dynamicdrive.com/forums/showthread.php?t=28882: (alternatives: http://codesnippets.joyent.com/posts/show/602 )*/ function ajaxFunction(id, url) { var xmlHttp; var elem = document.getElementById(id); try {// Firefox, Opera 8.0+, Safari xmlHttp = new XMLHttpRequest(); } catch (e2) {// Internet Explorer try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e3) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e4) { alert("Your browser does not support AJAX!"); return false; } } } xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState === 4) { //Get the response from the server and extract the section that comes in the body section of the second html page avoid inserting the header part of the second page in your first page's element var respText = xmlHttp.responseText.split(''); elem.innerHTML = respText[1].split('')[0]; } }; if (!elem) { alert('The element with the passed ID doesn\'t exists in your page'); return; } xmlHttp.open("GET", url, true); xmlHttp.send(null); }