テキストで入力した住所や地名などをGooglemapの中心に表示する方法です。
<script src="http://maps.google.com/maps/api/js?sensor=false"></script> <div id="googlemaps" style="width:100%; height:600px"></div> <script> var geo = new google.maps.Geocoder(); geo.geocode( { 'address': '明治神宮' }, function(result, status) { if (status == google.maps.GeocoderStatus.OK) { var latlng = new google.maps.LatLng( result[0].geometry.location.lat(), result[0].geometry.location.lng() ); var myOptions = { zoom: 12, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("googlemaps"), myOptions); } } ); </script>
- 関連記事
-
-
GoogleMapを任意の倍率で埋め込む 2015/04/10
-
HTML 文字背景は透過させて文字は透過させない方法 2015/04/03
-
GoogleMap API 文字で指定した住所を地図の中心にする 2015/04/02
-
IE7,8,9でiframeのYouTubeが最前面に表示されてしまう現象の対処法 2015/03/25
-
モバイルフレンドリー 2015/03/24
-