window.addEventListener('load' , function (){ var metaData = document.head.children; var metaLength = metaData.length; var mapsApiKey = ''; for(var i = 0;i < metaLength;i++){ var propertyName = metaData[i].getAttribute('name'); if( propertyName === 'c2googleMapsApiKey'){ mapsApiKey = metaData[i].getAttribute('content'); } } /* for googleAPI Key exists */ if( mapsApiKey.length > 0 ){ function initialize224() { var latlng224 = new google.maps.LatLng(34.56587, 135.49297); var pan=224; var myOptions224 = { zoom: 16, center: latlng224, mapTypeId: google.maps.MapTypeId.ROADMAP }; //centering if( document.getElementById(pan).children.length == 1 ) { if( document.getElementById(pan).children[0].children[0].tagName == 'BR' ) { var gmapDiv = document.getElementById(pan).children[0].children[3].children[0] } else { var gmapDiv = document.getElementById(pan).children[0].children[2].children[0] } } else { //beforeBR if( document.getElementById(pan).children[0].tagName == 'BR' ) { var gmapDiv = document.getElementById(pan).children[3].children[0] } else { var gmapDiv = document.getElementById(pan).children[2].children[0] } } var google_map224 = new google.maps.Map( gmapDiv, myOptions224 ); var marker224 = new google.maps.Marker({ position: latlng224, map: google_map224 }) } initialize224(); /* for googleAPI Key not exists(openStreetMap) */ }else{ var attr = document.getElementById(224); attr = attr.getElementsByTagName('center'); attr = attr[0].getElementsByTagName('div'); attr[0].setAttribute('id' , 'openStreetMap224'); var map224 = L.map( 'openStreetMap224' ).setView([34.56587,135.49297], 17 ); var tileLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{ attribution: '(c) OpenStreetMap contributors, CC-BY-SA', maxZoom: 19 }); tileLayer.addTo(map224); L.marker([34.56587,135.49297]).addTo(map224); } });