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

[ 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키 공개되어있습니다...!!

게시글 목록

번호 제목
23606
23598
23585
23579
23578
23564
23550
23549
23548
23529
23510
23507
23481
23471
23453
23452
23450
23436
23428
23404
23396
23389
23380
23369
23350
23337
23317
23307
23298
23290