Javascript & JQuery & CSS > Google Maps API + À§Ä¡Ç¥½Ã¿Í ¸»Ç³¼± ¶ç¿ì±â.
µî·ÏÀÏ : 2017-07-14 17:11
Á¶È¸¼ö : 53,521
±¸±ÛÁöµµ¸¦ À¥ÆäÀÌÁö¿¡ Àû¿ëÇßÀ» ¶§ÀÇ ¸ð½ÀÀÌ´Ù.
¹æ¹ýÀº ±²ÀåÈ÷ ½±´Ù.
»ç½Ç.. óÀ½¿¡ ¾Æ¹«°Íµµ ¸ô¶úÀ» ¶§´Â Á» ¾î·Á¿îµ¥, ¾Ë°í³ª¸é º° °Å ¾Æ´Ï´Ù.
https://developers.google.com/maps/documentation/javascript/
¾Æ·¡ ¼Ò½º¿¡ ÁÖ¼®À¸·Î ¼³¸íÀ» ´Þ¾Æ³ùÀ¸´Ï ÇÊ¿äÇÑ »ç¶÷Àº Âü°íÇÏ±æ ¹Ù¶õ´Ù.
*** ¸ÕÀú µ¶Å¸ÀÔÀ» HTML5 Çü½ÄÀ¸·Î ¸ÂÃçÁÙ °Í! "<!DOCTYPE html>"
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
¶Ç´Â,
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
±×¸®°í, ¾Æ·¡ ¼Ò½º¸¦ Ãß°¡ÇØ ÁÖ¸é µÈ´Ù.
//ÁÂÇ¥ À̹ÌÁö¸¦ Ç¥½ÃÇÏ´Â MarkerImage
var GreenIcon = new google.maps.MarkerImage(
"http://ankyu.entersoft.kr/images/choiankyu.jpg",
new google.maps.Size(60, 60),
new google.maps.Point(0, 0),
new google.maps.Point(6, 20));
//ÇöÀç À§Ä¡¿¡¼ À§µµ/°æµµ »Ì±â
function getLocation_cord()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(successCallback,errorCallback);
} else
{
$("#map").html("Geolocation is not supported by this browser.");
alert('´Ü¸»±â¿¡¼ ÇöÀç À§Ä¡¸¦ »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.');
}
}
//À§µµ/°æµµ ¼º°ø½Ã È£Ãâ Callback ÇÔ¼ö
function successCallback(wp_position)
{
//À§µµ °æµµ Ç¥½Ã
$("#setPosition").html("Latitude: " + wp_position.coords.latitude + ", Longitude: " + wp_position.coords.longitude);
var wplatlng = new google.maps.LatLng(wp_position.coords.latitude, wp_position.coords.longitude);
var wpOptions = {
zoom:19, // Áöµµ zoom´Ü°è
center:wplatlng, //Áöµµ¿¡¼ °¡¿îµ¥·Î À§Ä¡ÇÒ À§µµ¿Í °æµµ(º¯¼ö)
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var wpmap = new google.maps.Map(document.getElementById("map"), wpOptions);
var marker = new google.maps.Marker({
map: wpmap,
icon: GreenIcon, // ¸¶Ä¿·Î »ç¿ëÇÒ À̹ÌÁö(º¯¼ö)
info: "¸»Ç³¼±", // ¸»Ç³¼± ¾È¿¡ µé¾î°¥ ³»¿ë.
title : "ÇöÀçÀ§Ä¡", // ¸¶Ä¿¿¡ ¸¶¿ì½º Æ÷ÀÎÆ®¸¦ °®´Ù´òÀ» ¶§ ¶ß´Â ŸÀÌƲ.
position: wplatlng // ¸¶Ä¿ Ç¥½Ã ÁÂÇ¥.
});
var content = "ÀÌ°÷Àº ¸»Ç³¼± Å×½ºÆ® ÇÏ´Â °÷ ÀÔ´Ï´Ù. "; // ¸»Ç³¼± ¾È¿¡ µé¾î°¥ ³»¿ë
// ¸¶Ä¿¸¦ Ŭ¸¯ÇßÀ» ¶§ÀÇ À̺¥Æ®. ¸»Ç³¼± »Ð~
var infowindow = new google.maps.InfoWindow({ content: content});
google.maps.event.addListener(marker, "click", function() {
infowindow.open(wpmap,marker);
});
}
//À§µµ °æµµ ½ÇÆнÃ
function errorCallback(wp_position_error)
{
// ½ÇÆÐ ÄÚµå¿Í ¸Þ¼¼Áö Ãâ·Â
$("#map").html("error.code : "+ wp_position_error.code + " , error.message : " + wp_position_error.message);
}
google.maps.event.addDomListener(window, 'load', getLocation_cord);