var map; var address="大分県大分市大字廻栖野2944の9"; var name="大分県立看護科学大学"; var tel=""; var ido_keido = ""; var lat = ""; var lng = ""; //var myLatlng; window.onload = function(){ var geocoder; if(ido_keido == ""){ geocoder = new google.maps.Geocoder(); geocoder.geocode({ address: address }, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { myLatlng = results[0].geometry.location; // スコープ外で値が消える makemap(myLatlng) } else { //alert("住所・所在地から地図を取得できませんでした"); } }); }else{ myLatlng = new google.maps.LatLng(lat, lng); makemap(myLatlng) } } function makemap(myLatlng){ var txt="
" + "" + name + "<\/b>
" + address + "<\/div>"; var myOptions = { zoom: 14, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("map"), myOptions); var marker = new google.maps.Marker({ position: myLatlng, map: map }); var infowindow = new google.maps.InfoWindow({ content: txt }); google.maps.event.addListener(marker, 'click', function() {infowindow.open(map,marker); }); }