개발관련/Google API GoogleMap 좌표 변환(주소 -> lat,lng 로 변환) - SMALL #기본 좌표 초기화 <? //기본 좌표 지정 $lat = "22.2627924"; $lng = "113.96554190000006"; $mappoint = $lat.','.$lng; ?> 스크립트 <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> // // Google map Api // var gmap; var markers = []; var geocoder; var centericon = []; function initialize() { geocoder = new google.maps.Geocoder(); var subgps; var latlng = new google.maps.LatLng(<?= $mappoint?>); var myOptions = { zoom: 16, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; gmap = new google.maps.Map(document.getElementById("map_canvas"), myOptions); //makeMarker(shopinfo); centericon = new google.maps.Marker({ position: subgps, map: gmap, icon:'/target.png' }); google.maps.event.addListener(gmap, 'mousemove', function(e) { subgps = gmap.getCenter(); centericon.setPosition(subgps); //test code document.getElementById('lat').innerHTML = gmap.getCenter(); }); } function changeCenter(){ var p = gmap.getCenter(); self.location.href = "<?= $PHP_SELF?>?shopid=<?= $shopid?>&work=change&ll=" + p.lat() + ',' + p.lng(); } function makeMarker(location) { var markerOptions = {map: gmap, position: new google.maps.LatLng(location.lat, location.lng)}; var marker = new google.maps.Marker(markerOptions); markers.push(marker); } function codeAddress() { // // 실제 반영 주소 넣기 // address = "여기에 실제 주소를 넣어주세요."; geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { gmap.setCenter(results[0].geometry.location); subgps = gmap.getCenter(); centericon.setPosition(subgps); //test code document.getElementById('lat').innerHTML = gmap.getCenter(); } else { alert("none address: " + status); } }); } // // Google Map Api End // </script> <div id="map_canvas" style="width: 500px; height: 400px"></div> <div id="lat"></div> <div id="lng"></div> LIST 좋아요공감공유하기 URL 복사카카오톡 공유페이스북 공유엑스 공유 게시글 관리 구독하기기록하자 잊어먹지말고~ 저작자표시 비영리 동일조건 Contents 댓글 0 + 이전 댓글 더보기 기록하자 잊어먹지말고~자주 잊어먹는것들을 기록해 놓을려고합니다.^^구독하기