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 initialize193() { var latlng193 = new google.maps.LatLng(35.16877, 136.89104); var pan=193; var myOptions193 = { zoom: 16, center: latlng193, 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_map193 = new google.maps.Map( gmapDiv, myOptions193 ); var marker193 = new google.maps.Marker({ position: latlng193, map: google_map193 }) } initialize193(); /* for googleAPI Key not exists(openStreetMap) */ }else{ var attr = document.getElementById(193); attr = attr.getElementsByTagName('center'); attr = attr[0].getElementsByTagName('div'); attr[0].setAttribute('id' , 'openStreetMap193'); var map193 = L.map( 'openStreetMap193' ).setView([35.16877,136.89104], 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(map193); L.marker([35.16877,136.89104]).addTo(map193); } });