function log() { } function showMapProcess(func) { log(); var address = '神奈川県 座間市 緑ケ丘6-20-10'; address = '神奈川県 座間市 緑ケ丘'; var geocoder = new google.maps.Geocoder(); // geocoder.geocode()メソッドを実行 geocoder.geocode( { 'address': address}, function(results, status) { if (status != google.maps.GeocoderStatus.OK) { // ジオコーディングが成功しなかった場合 console.log('Geocode was not successful for the following reason: ' + status); return; } // ジオコーディングが成功した場合、変換した緯度・経度情報を返却 func(results[0].geometry.location); }); } function showMap() { showMapProcess( function(point) { // 地図表示に関するオプション var mapOptions = { zoom: 16, mapTypeId: google.maps.MapTypeId.ROADMAP, center: new google.maps.LatLng(point.lat(), point.lng()) }; // 地図を表示させるインスタンスを生成 var map = new google.maps.Map(document.getElementById("googlemap"), mapOptions); //map.setCenter(point); } ); } function showStaticMap() { showMapProcess( function(point) { var url = "https://maps.googleapis.com/maps/api/staticmap?center="+point.toUrlValue()+"&zoom=16&size=160x160&key=AIzaSyB0vZjDy0o1PR9JM42Yo8YBMxaroZBxStI&sensor=false"; $("#googlestaticmap").attr('src',url); } ); } function setHref(obj) { showMapProcess( function(point) { var url = "//maps.google.com/maps?q="+point.toUrlValue()+"&zoom=16"; obj.attr('href',url); } ); }