테스트 사이트 - 개발 중인 베타 버전입니다

[ PHP ] Geoip , 지도에서 아이피위치 불러오기

구글지도에서 아이피 위치를 표시해줍니다.

 

<div id="map"></div>
   <script>
      function initMap() {
        var map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: -34.397, lng: 150.644},
          zoom: 15
        });
        var infoWindow = new google.maps.InfoWindow({map: map});

        // Try HTML5 geolocation.
        if (navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(function(position) {
            var pos = {
              lat: position.coords.latitude,
              lng: position.coords.longitude
            };

            infoWindow.setPosition(pos);
            infoWindow.setContent('현 위치');
            map.setCenter(pos);
          }, function() {
            handleLocationError(true, infoWindow, map.getCenter());
          });
        } else {
          // Browser doesn't support Geolocation
          handleLocationError(false, infoWindow, map.getCenter());
        }
      }

      function handleLocationError(browserHasGeolocation, infoWindow, pos) {
        infoWindow.setPosition(pos);
        infoWindow.setContent(browserHasGeolocation ?
                              'Error: 서비스에 에러가 발생했습니다. 브라우저의 위치권한을 허용해주세요.' :
                              'Error: 브라우저 호환성이 떨어집니다. 크롬으로 바꾸는건 어떤가요?');
      }
    </script>
    <script async defer
    src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBfIM2TFBCJ-sf6MFz-eobXsWk2NU1ec70&callback=initMap">
    </script>
    

 

위치추적도 만들수 있을거같아요 네비게이션..??

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 1개

API키 공개되어있습니다...!!

게시글 목록

번호 제목
23798
23797
23792
23791
23785
23781
23770
23766
23764
23761
23747
23732
23724
23718
23706
23700
23697
23686
23682
23681
23680
23678
23665
23644
23643
23639
23637
23630
23626
23616