My Name is Kay....

DIY , 먹방 , 개발 , 육아 , 여행 좋아합니다.
AdBlock 사용시 화면이 정상적으로 노출되지 않습니다.
포스팅 관련 문의 및 개발 문의는 Email : wkzkfmxksi@gmail.com

추가 포스팅이 이뤄지지 않는 블로그입니다. 문의는 wkzkfmxksi@gmail.com 으로 연락주세요.
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

현재 위치를 읽어와서 구글맵에 마커를 표시해주는 기능입니다.


Test Url : http://www.uhoon.co.kr/test/1208.html


getCurrentPosition+googlemap.png


<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>getCurrentPosition + Googlemap marker </title>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script type="text/javascript">
<!--
	function fnGetCurrentPosition() {
	  	if (navigator.geolocation)
		{
			$("#latlng").html("");
			$("#errormsg").html("");
			navigator.geolocation.getCurrentPosition (function (pos)
			{
				lat = pos.coords.latitude;
				lng = pos.coords.longitude;

				$("#latlng").html("latitude : " + lat + "<br/> longitude : "+ lng);

				var mapOptions = {
					zoom: 16,
					mapTypeId: google.maps.MapTypeId.ROADMAP,
					center: new google.maps.LatLng(lat,lng)
				};

				map = new google.maps.Map(document.getElementById('map'),mapOptions);

				var myIcon = new google.maps.MarkerImage("http://google-maps-icons.googlecode.com/files/restaurant.png", null, null, null, new google.maps.Size(17,17));
				var marker = new google.maps.Marker({
					position: new google.maps.LatLng(lat,lng),
					map: map,
					draggable: false,
					icon: myIcon
				});
				markers.push(marker);
			},function(error)
			{
				switch(error.code)
				{
					case 1:
						$("#errormsg").html("User denied the request for Geolocation.");
						break;
					case 2:
						$("#errormsg").html("Location information is unavailable.");
						break;
					case 3:
						$("#errormsg").html("The request to get user location timed out.");
						break;
					case 0:
						$("#errormsg").html("An unknown error occurred.");
						break;
				}
			});
		}
		else
		{
			$("#errormsg").html("Geolocation is not supported by this browser.");
		}
	}
//-->
</script>
</head>
<body>
<div id="errormsg"></div>
<div id="latlng"></div>
<input type="button" value="GetCurrentPosition " onclick="Javascript:fnGetCurrentPosition();" />
<div id="map" style="width:760px;height:400px;margin-top:20px;"></div>
</body>
</html>



getCurrentPosition 자세히 알아보기 : http://www.uhoon.co.kr/API/1200


?

  1. 구글맵 v3 infoBox

    Date2015.12.29 Categorymap Bykay Views2966
    Read More
  2. 구글맵 v3 단순 다중 마커 (배열이용)

    Date2015.12.28 Categorymap Bykay Views10271
    Read More
  3. 구글맵 마커 + 말풍선 - v3

    Date2015.02.05 Categorymap Bykay Views3280
    Read More
  4. 구글맵 v3 맵상에 보여지는 마커만 생성하기

    Date2014.08.04 Categorymap Bykay Views7602
    Read More
  5. 구글맵 v3 - 마커 + 말풍선 + GPS 연동+ 원그리기 + 동적 마커 생성( Ajax + Json )

    Date2014.07.17 Categorymap Bykay Views16931
    Read More
  6. Google 웹사이트 번역기

    Date2014.04.21 Category기타 Bykay Views5318
    Read More
  7. Google Places API를 이용한 주변 지역 정보 검색

    Date2013.10.18 Categorymap Bykay Views21310
    Read More
  8. GeoRSS 피드에서 KmlLayer를 생성..." geoRSS 로 레이어 마커 찍기 "

    Date2013.08.28 Categorymap Bykay Views5244
    Read More
  9. 구글맵 API 적용범위 (Google Maps API Coverage)

    Date2013.08.27 Categorymap Bykay Views4977
    Read More
  10. google 스트릿뷰 "Street View"

    Date2013.08.27 Categorymap Bykay Views4708
    Read More
  11. 브라우져에서 현재 위경도 읽어와서 구글맵에 마커 표시하기 ( getCurrentPosition + Googlemap marker )

    Date2013.05.31 Categorymap Bykay Views24276
    Read More
  12. 구글맵 출발지 도착지 주소입력해서 길찾기 - v3

    Date2013.05.03 Categorymap Bykay Views29012
    Read More
  13. 모바일 웹 - 위치정보(GPS) + 마커 + 카톡 + 카스 연동

    Date2013.04.24 Categorymap Bykay Views10243
    Read More
  14. 구글맵 아이콘 마커 + 말풍선 + 주소로 위경도 검색 + 거리별 원그리기 - v3

    Date2013.04.22 Categorymap Bykay Views14720
    Read More
  15. geocode - 주소로 위경도 검색 v3

    Date2013.04.21 Categorymap Bykay Views8050
    Read More
  16. 구글맵 마커 + 말풍선 - v2

    Date2013.02.06 Categorymap Bykay Views10982
    Read More
  17. geocode - 구글 맵 위경도 검색 v2

    Date2013.02.06 Categorymap Bykay Views7299
    Read More
  18. 막대 그래프

    Date2013.02.06 CategoryGraph Bykay Views8503
    Read More
  19. 선 + 막대 그래프

    Date2013.02.06 CategoryGraph Bykay Views8665
    Read More
  20. 선 그래프

    Date2013.02.06 CategoryGraph Bykay Views6300
    Read More
Board Pagination Prev 1 Next
/ 1