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 initialize132() { var latlng132 = new google.maps.LatLng(34.50481, 136.79149); var pan=132; var myOptions132 = { zoom: 16, center: latlng132, 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_map132 = new google.maps.Map( gmapDiv, myOptions132 ); var marker132 = new google.maps.Marker({ position: latlng132, map: google_map132 }) } initialize132(); /* for googleAPI Key not exists(openStreetMap) */ }else{ var attr = document.getElementById(132); attr = attr.getElementsByTagName('center'); attr = attr[0].getElementsByTagName('div'); attr[0].setAttribute('id' , 'openStreetMap132'); var map132 = L.map( 'openStreetMap132' ).setView([34.50481,136.79149], 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(map132); L.marker([34.50481,136.79149]).addTo(map132); } });