[Google API] 구글맵 v3 infoBox

Open API/Google|2016.12.14 23:13



구글맵 infoWindow 만으로는 html 사용에 제약이 많습니다.

디자인 소스 적용이 어렵기 때문입니다.


해결을 위해 플러그인이 제공되고 있습니다.

그 이름 " infoBox" !!


좀더 자유롭게 디자인 소스를 입힐 수 있는데요.


사용하기 위해서는 infobox.js 를 추가해야 합니다.

JS : 다운로드



샘플 코드 :   http://www.uhoon.co.kr/test/6502.html


** 기본 infoWindow에서는 불가능 했던 각종 옵션들이 무궁무진합니다. ** 


API Reference :  

http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html


<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?v=3&sensor=false"></script>
<script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/src/infobox.js"></script>
<script type="text/javascript">
	function initialize() {
		var secheltLoc = new google.maps.LatLng(49.47216, -123.76307);

		var myMapOptions = {
			 zoom: 15
			,center: secheltLoc
			,mapTypeId: google.maps.MapTypeId.ROADMAP
		};
		var theMap = new google.maps.Map(document.getElementById("map_canvas"), myMapOptions);


		var marker = new google.maps.Marker({
			map: theMap,
			draggable: true,
			position: new google.maps.LatLng(49.47216, -123.76307),
			visible: true
		});

		var boxText = document.createElement("div");
		boxText.style.cssText = "border: 1px solid black; margin-top: 8px; background: yellow; padding: 5px;";
		boxText.innerHTML = "City Hall, Sechelt<br>British Columbia<br>Canada";

		var myOptions = {
			 content: boxText
			,disableAutoPan: false
			,maxWidth: 0
			,pixelOffset: new google.maps.Size(-140, 0)
			,zIndex: null
			,boxStyle: { 
			  background: "url('tipbox.gif') no-repeat"
			  ,opacity: 0.75
			  ,width: "280px"
			 }
			,closeBoxMargin: "10px 2px 2px 2px"
			,closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif"
			,infoBoxClearance: new google.maps.Size(1, 1)
			,isHidden: false
			,pane: "floatPane"
			,enableEventPropagation: false
		};

		google.maps.event.addListener(marker, "click", function (e) {
			ib.open(theMap, this);
		});

		var ib = new InfoBox(myOptions);

		ib.open(theMap, marker);
	}
</script>

<title>Creating and Using an InfoBox</title>
</head>
<body onload="initialize()">
	<div id="map_canvas" style="width: 100%; height: 400px"></div>
	<p>
	This example shows the "traditional" use of an InfoBox as a replacement for an InfoWindow.
</body>

</html>


댓글()

Google API 구글맵 아이콘 마커 + 말풍선 + 주소로 위경도 검색 + 거리별 원그리기 - v3

Open API/Google|2016.11.21 18:16



구글맵 V3 기본 기능입니다..

다음번에는 길찾기 등...animation 쪽으로..


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



* 기능

 기본 맵

 아이콘 마커 (marker)

 말풍선 (infoWindow)

 주소로 위경도 검색하기 (geocoder)

 거리별 중심점 기준으로 원그리기 ( Circle )



<!doctype html>
<html>
<head>
	<meta charset="utf-8" />
	<title>googlemap v3 </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>
</head>
<SCRIPT LANGUAGE="JavaScript">
<!--
var contentArray = [];
var iConArray = [];
var markers = [];
var iterator = 0;
var map;
var geocoder;

// infowindow contents 배열
 contentArray[0] = "Kay";
 contentArray[1] = "uhoons blog";
 contentArray[2] = "blog.uhoon.co.kr";
 contentArray[3] = "www.suvely.com";
 contentArray[4] = "www.babbabo.com";
 contentArray[5] = "blog.goodkiss.co.kr";
 contentArray[6] = "GG";
 contentArray[7] = "blog.goodkiss.co.kr";
 contentArray[8] = "II";
 contentArray[9] = "blog.goodkiss.co.kr";

// marker icon 배열
 iConArray[0] = "http://google-maps-icons.googlecode.com/files/walking-tour.png";
 iConArray[1] = "http://google-maps-icons.googlecode.com/files/walking-tour.png";
 iConArray[2] = "http://google-maps-icons.googlecode.com/files/walking-tour.png";
 iConArray[3] = "http://google-maps-icons.googlecode.com/files/walking-tour.png";
 iConArray[4] = "http://google-maps-icons.googlecode.com/files/walking-tour.png";
 iConArray[5] = "http://google-maps-icons.googlecode.com/files/walking-tour.png";
 iConArray[6] = "http://google-maps-icons.googlecode.com/files/walking-tour.png";
 iConArray[7] = "http://google-maps-icons.googlecode.com/files/walking-tour.png";
 iConArray[8] = "http://google-maps-icons.googlecode.com/files/walking-tour.png";
 iConArray[9] = "http://google-maps-icons.googlecode.com/files/walking-tour.png";

// 위경도 배열
var markerArray = [ new google.maps.LatLng(40.3938,-3.7077)
, new google.maps.LatLng(40.45038,-3.69803)
, new google.maps.LatLng(40.45848,-3.69477)
, new google.maps.LatLng(40.40672,-3.68327)
, new google.maps.LatLng(40.43672,-3.62093)
, new google.maps.LatLng(40.46725,-3.67443)
, new google.maps.LatLng(40.43794,-3.67228)
, new google.maps.LatLng(40.46212,-3.69166)
, new google.maps.LatLng(40.41926,-3.70445)
, new google.maps.LatLng(40.42533,-3.6844)
];

function initialize() {
	geocoder = new google.maps.Geocoder();

	var mapOptions = {
		zoom: 11,
		mapTypeId: google.maps.MapTypeId.ROADMAP,
		center: new google.maps.LatLng(40.4167754,-3.7037901999999576)
	};

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

	var populationOptions = {
		strokeColor: '#000000',
		strokeOpacity: 0.8,
		strokeWeight: 2,
		fillColor: '#808080',
		fillOpacity: 0.5,
		map: map,
		center: new google.maps.LatLng(40.4167754,-3.7037901999999576) ,
		radius: $("#radius").val()*1000
	};
	cityCircle = new google.maps.Circle(populationOptions);
}

// 주소 검색
function showAddress() {
	var address = $("#address").val();
	geocoder.geocode( { 'address': address}, function(results, status) {
		if (status == google.maps.GeocoderStatus.OK) {
			map.setCenter(results[0].geometry.location);
			var marker = new google.maps.Marker({
				map: map,
				position: results[0].geometry.location,
				draggable: true
			});

			google.maps.event.addListener(marker, "dragend", function(event) {
				var point = marker.getPosition();
				$("#latitude").val(point.lat());
				$("#longitude").val(point.lng());

				var populationOptions = {
					strokeColor: '#000000',
					strokeOpacity: 0.8,
					strokeWeight: 2,
					fillColor: '#808080',
					fillOpacity: 0.5,
					map: map,
					center: new google.maps.LatLng($("#latitude").val(),$("#longitude").val()) ,
					radius: $("#radius").val()*1000
				};
				if (cityCircle)
				{
					cityCircle.setMap(null);
				}
				cityCircle = new google.maps.Circle(populationOptions);
			});

			var lat = results[0].geometry.location.lat();
			var lng = results[0].geometry.location.lng();

			$("#latitude").val(lat);
			$("#longitude").val(lng);

			var populationOptions = {
				strokeColor: '#000000',
				strokeOpacity: 0.8,
				strokeWeight: 2,
				fillColor: '#808080',
				fillOpacity: 0.5,
				map: map,
				center: new google.maps.LatLng(lat,lng) ,
				radius: $("#radius").val()*1000
			};
			if (cityCircle)
			{
				cityCircle.setMap(null);
			}
			cityCircle = new google.maps.Circle(populationOptions);

		} else {
			alert('Geocode was not successful for the following reason: ' + status);
		}
	});
}

// 드롭 마커 보기
function viewMarker() {
	for (var i = 0; i < markerArray.length; i++) {
		setTimeout(function() {
			addMarker();
		}, i * 300);
	}

	var marker = new google.maps.Marker ({
			position: new google.maps.LatLng(40.4167754,-3.7037901999999576),
			map: map,
			draggable: true
		});

	google.maps.event.addListener(marker, "dragend", function(event) {
		var point = marker.getPosition();
		$("#latitude").val(point.lat());
		$("#longitude").val(point.lng());

		var populationOptions = {
			strokeColor: '#000000',
			strokeOpacity: 0.8,
			strokeWeight: 2,
			fillColor: '#808080',
			fillOpacity: 0.5,
			map: map,
			center: new google.maps.LatLng($("#latitude").val(),$("#longitude").val()) ,
			radius: $("#radius").val()*1000
		};
		if (cityCircle)
		{
			cityCircle.setMap(null);
		}
		cityCircle = new google.maps.Circle(populationOptions);
	});
}

// 마커 추가
function addMarker() {

	var marker = new google.maps.Marker({
		position: markerArray[iterator],
		map: map,
		draggable: false,
		icon: iConArray[iterator],
		animation: google.maps.Animation.DROP
	});
	markers.push(marker);

	var infowindow = new google.maps.InfoWindow({
      content: contentArray[iterator]
	});

	google.maps.event.addListener(marker, 'click', function() {
		infowindow.open(map,marker);
	});
	iterator++;
}

// 중심 이동
function fnLocation(lat, lng) {
	myLocation = new google.maps.LatLng(lat, lng);
	map.setCenter(myLocation);
}

//google.maps.event.addDomListener(window, 'load', initialize);

$( window ).load(function() {
	initialize();
	viewMarker();
});

//-->
</SCRIPT>
<body>
radius : <select id="radius" >
	<option value="10" selected="selected">10Km</option>
	<option value="5">5Km</option>
</select>
latitude : <input type="text" id="latitude" value="40.4167754"/>
longitude: <input type="text" id="longitude" value="-3.7037901999999576"/>
<div id="map" style="width:760px;height:400px;margin-top:20px;"></div>
<label style="margin:3px 0 0 0;" for="address">address</label>
<input type="text" id="address" name="address" style="margin:3px 0 0 5px;" value=""/>
<input type="button" value="search" onclick="Javascript:showAddress();" />
</body>
</html>


댓글()

jQuery Tiptip - 툴팁 ( tooltip )

Open API/Jquery|2016.11.01 10:07



툴팁에 대한  플러그인 입니다.


툴팁이란 ?   

말풍선 또는 툴팁(tooltip)은 공통 그래픽 사용자 인터페이스 요소이다. 마우스 포인터라 불리는 커서와 함께 동작한다. 사용자가 커서에 항목을 클릭하지 않고 가리키면 조그마한 상자가 항목 위에 나타나서 보충 설명을 보여 준다.




API Url : http://code.drewwilson.com/entry/tiptip-jquery-plugin



샘플코드 다운로드 :  454.7z


옵션 값.

activation: string ("hover" by default) - jQuery method TipTip is activated with. Can be set to: "hover", "focus" or "click".
keepAlive: true of false (false by default) - When set to true the TipTip will only fadeout when you hover over the actual TipTip and then hover off of it.
maxWidth: string ("200px" by default) - CSS max-width property for the TipTip element. This is a string so you can apply a percentage rule or 'auto'.
edgeOffset: number (3 by default) - Distances the TipTip popup from the element with TipTip applied to it by the number of pixels specified.
defaultPosition: string ("bottom" by default) - Default orientation TipTip should show up as. You can set it to: "top", "bottom", "left" or "right".
delay: number (400 by default) - Number of milliseconds to delay before showing the TipTip popup after you mouseover an element with TipTip applied to it.
fadeIn: number (200 by default) - Speed at which the TipTip popup will fade into view.
fadeOut: number (200 by default) - Speed at which the TipTip popup will fade out of view.
attribute: string ("title" by default) - HTML attribute that TipTip should pull it's content from.
content: string (false by default) - HTML or String to use as the content for TipTip. Will overwrite content from any HTML attribute.
enter: callback function - Custom function that is run each time you mouseoveran element with TipTip applied to it.
exit: callback function - Custom function that is run each time you mouseout of an element with TipTip applied to it.






<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Mangled date examples</title> 
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="/test/454/jquery.tipTip.js"></script>  
<link rel="stylesheet" type="text/css" href="/test/454/tiptip.css"/>
<script type="text/javascript">
	$(function(){
		$(".someClass").tipTip();
	});
</script> 
<style type="text/css">
	.sample {padding-bottom:20px;}
</style>
</head>
<body>
<div class="sample">
	<a href="#" class="someClass" title="요거이 Text">텍스트</a>에다가 타이틀로 넣으면 되구요.
</div> 
<div class="sample">
	<img src="/files/attach/images/106/893/b0183fae643bfa50ebef8ce046e5abe8.jpg" class="someClass" title="요거이 이미지" style="width:200px;height:150px;"/>
 </div>
<div class="sample">
	<input class="someClass" title="요거이 인풋" style="width:200px;"/>
 </div>
</body>
</html>


댓글()

다음맵 api 마커 + 말풍선

Open API/Daum|2016.10.31 09:12



다음맵 API를 이용한 기본 마커 + 말풍선 샘플 코드입니다.


<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width, target-densityDpi=device-dpi"> <title>용산전쟁기념관</title> <style type="text/css"> html, body, #map {margin: 0; padding: 0; width: 100%; height: 100%} </style> <script type="text/javascript" src="http://apis.daum.net/maps/maps3.js?apikey=DAUM_MAPS_DEMO_APIKEY" charset="utf-8"></script> <script type="text/javascript"> var map; function init() { map = new daum.maps.Map(document.getElementById('map'), { center: new daum.maps.LatLng(37.53592870797618, 126.97726376303085) });    var icon = new daum.maps.MarkerImage( 'http://maps.google.com/mapfiles/kml/pal3/icon46.png', new daum.maps.Size(20, 20), new daum.maps.Point(20, 20) ); var marker = new daum.maps.Marker({ position: new daum.maps.LatLng(37.5367, 126.9772), image : icon }); marker.setMap(map);    var infowindow = new daum.maps.InfoWindow({ content: '<a href="http://www.warmemo.co.kr" target="_blank" style="margin:1em;line-height:2;text-decoration:none">장소 : 용산전쟁기념관 기획전시실   <BR>     프로그램명: 코코몽 녹색놀이터 <br>     기간 : 2012.12.01-2012.12.31<br>     예약현황 : 80개 단체 5000명(현재)</a>' });   daum.maps.event.addListener(marker, "click", function() { infowindow.open(map, marker); });   daum.maps.event.addListener(map, "click", function() { infowindow.close(); });     var marker1 = new daum.maps.Marker({ position: new daum.maps.LatLng(37.5245, 126.9805), image : icon });   marker1.setMap(map); var infowindow1 = new daum.maps.InfoWindow({ content: '<a href="http://www.museum.go.kr" target="_blank" style="margin:1em;line-height:2;text-decoration:none">장소 : 국립중앙 박물관   <BR>     프로그램명: 2013 웨딩페어 <BR>     기간 : 2012.12.01-2012.12.31<BR>     예약현황 : 2개 단체 20000명(현재)</a>' });   daum.maps.event.addListener(marker1, "click", function() { infowindow1.open(map, marker1); });   daum.maps.event.addListener(map, "click", function() { infowindow1.close(); }); } </script> </head> <body onload="init()"> <div id="map"></div>    </body> </html>


댓글()