³»Á¤º¸

ÁÖ¹®Á¶È¸.°ü¸®

Ä¿¹Â´ÏƼ

¼Ö·ç¼Ç °ü·Ã °Ô½ÃÆÇ
 


 

Å׸¶Çü ÀÚÀ¯°Ô½ÃÆÇ

 


¤ýÀÛ¼ºÀÚ
¤ýÀÛ¼ºÀÏ 2013/07/19 23:43
¤ýºÐ ·ù ±¸±ÛÁöµµ(map)
¤ýÁ¶È¸: 2831      
¤ýIP: 180.xxx.247
InfoWindow ÀÚµ¿ ¶ç¿ì±â - v3
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API v3 Example: Info Window Custom</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">

/* An InfoBox is like an info window, but it displays
* under the marker, opens quicker, and has flexible styling.
* @param {GLatLng} latlng Point to place bar at
* @param {Map} map The map on which to display this InfoBox.
* @param {Object} opts Passes configuration options - content,
* offsetVertical, offsetHorizontal, className, height, width
*/
function InfoBox(opts) {
google.maps.OverlayView.call(this);
this.latlng_ = opts.latlng;
this.map_ = opts.map;
this.offsetVertical_ = -195;
this.offsetHorizontal_ = 0;
this.height_ = 165;
this.width_ = 266;

var me = this;
this.boundsChangedListener_ =
google.maps.event.addListener(this.map_, "bounds_changed", function() {
return me.panMap.apply(me);
});

// Once the properties of this OverlayView are initialized, set its map so
// that we can display it. This will trigger calls to panes_changed and
// draw.
this.setMap(this.map_);
}

/* InfoBox extends GOverlay class from the Google Maps API
*/
InfoBox.prototype = new google.maps.OverlayView();

/* Creates the DIV representing this InfoBox
*/
InfoBox.prototype.remove = function() {
if (this.div_) {
this.div_.parentNode.removeChild(this.div_);
this.div_ = null;
}
};

/* Redraw the Bar based on the current projection and zoom level
*/
InfoBox.prototype.draw = function() {
// Creates the element if it doesn't exist already.
this.createElement();
if (!this.div_) return;

// Calculate the DIV coordinates of two opposite corners of our bounds to
// get the size and position of our Bar
var pixPosition = this.getProjection().fromLatLngToDivPixel(this.latlng_);
if (!pixPosition) return;

// Now position our DIV based on the DIV coordinates of our bounds
this.div_.style.width = this.width_ + "px";
this.div_.style.left = (pixPosition.x + this.offsetHorizontal_) + "px";
this.div_.style.height = this.height_ + "px";
this.div_.style.top = (pixPosition.y + this.offsetVertical_) + "px";
this.div_.style.display = 'block';
};

/* Creates the DIV representing this InfoBox in the floatPane. If the panes
* object, retrieved by calling getPanes, is null, remove the element from the
* DOM. If the div exists, but its parent is not the floatPane, move the div
* to the new pane.
* Called from within draw. Alternatively, this can be called specifically on
* a panes_changed event.
*/
InfoBox.prototype.createElement = function() {
var panes = this.getPanes();
var div = this.div_;
if (!div) {
// This does not handle changing panes. You can set the map to be null and
// then reset the map to move the div.
div = this.div_ = document.createElement("div");
div.style.border = "0px none";
div.style.position = "absolute";
div.style.background = "url('http://gmaps-samples.googlecode.com/svn/trunk/images/blueinfowindow.gif')";
div.style.width = this.width_ + "px";
div.style.height = this.height_ + "px";
var contentDiv = document.createElement("div");
contentDiv.style.padding = "30px"
contentDiv.innerHTML = "<b>Hello World!</b>";

var topDiv = document.createElement("div");
topDiv.style.textAlign = "right";
var closeImg = document.createElement("img");
closeImg.style.width = "32px";
closeImg.style.height = "32px";
closeImg.style.cursor = "pointer";
closeImg.src = "http://gmaps-samples.googlecode.com/svn/trunk/images/closebigger.gif";
topDiv.appendChild(closeImg);

function removeInfoBox(ib) {
return function() {
ib.setMap(null);
};
}

google.maps.event.addDomListener(closeImg, 'click', removeInfoBox(this));

div.appendChild(topDiv);
div.appendChild(contentDiv);
div.style.display = 'none';
panes.floatPane.appendChild(div);
this.panMap();
} else if (div.parentNode != panes.floatPane) {
// The panes have changed. Move the div.
div.parentNode.removeChild(div);
panes.floatPane.appendChild(div);
} else {
// The panes have not changed, so no need to create or move the div.
}
}

/* Pan the map to fit the InfoBox.
*/
InfoBox.prototype.panMap = function() {
// if we go beyond map, pan map
var map = this.map_;
var bounds = map.getBounds();
if (!bounds) return;

// The position of the infowindow
var position = this.latlng_;

// The dimension of the infowindow
var iwWidth = this.width_;
var iwHeight = this.height_;

// The offset position of the infowindow
var iwOffsetX = this.offsetHorizontal_;
var iwOffsetY = this.offsetVertical_;

// Padding on the infowindow
var padX = 40;
var padY = 40;

// The degrees per pixel
var mapDiv = map.getDiv();
var mapWidth = mapDiv.offsetWidth;
var mapHeight = mapDiv.offsetHeight;
var boundsSpan = bounds.toSpan();
var longSpan = boundsSpan.lng();
var latSpan = boundsSpan.lat();
var degPixelX = longSpan / mapWidth;
var degPixelY = latSpan / mapHeight;

// The bounds of the map
var mapWestLng = bounds.getSouthWest().lng();
var mapEastLng = bounds.getNorthEast().lng();
var mapNorthLat = bounds.getNorthEast().lat();
var mapSouthLat = bounds.getSouthWest().lat();

// The bounds of the infowindow
var iwWestLng = position.lng() + (iwOffsetX - padX) * degPixelX;
var iwEastLng = position.lng() + (iwOffsetX + iwWidth + padX) * degPixelX;
var iwNorthLat = position.lat() - (iwOffsetY - padY) * degPixelY;
var iwSouthLat = position.lat() - (iwOffsetY + iwHeight + padY) * degPixelY;

// calculate center shift
var shiftLng =
(iwWestLng < mapWestLng ? mapWestLng - iwWestLng : 0) +
(iwEastLng > mapEastLng ? mapEastLng - iwEastLng : 0);
var shiftLat =
(iwNorthLat > mapNorthLat ? mapNorthLat - iwNorthLat : 0) +
(iwSouthLat < mapSouthLat ? mapSouthLat - iwSouthLat : 0);

// The center of the map
var center = map.getCenter();

// The new map center
var centerX = center.lng() - shiftLng;
var centerY = center.lat() - shiftLat;

// center the map to the new shifted center
map.setCenter(new google.maps.LatLng(centerY, centerX));

// Remove the listener after panning is complete.
google.maps.event.removeListener(this.boundsChangedListener_);
this.boundsChangedListener_ = null;
};

function initialize() {
var myOptions = {
zoom: 8,
center: new google.maps.LatLng(-33.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP,
sensor: 'true'
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

var marker = new google.maps.Marker({
position: new google.maps.LatLng(-34, 150),
map: map
});
google.maps.event.addListener(marker, "click", function(e) {
var infoBox = new InfoBox({latlng: marker.getPosition(), map: map});
});
google.maps.event.trigger(marker, "click");
}
</script>
</head>
<body style="margin:0px; padding:0px;" onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>
   

   
¹øÈ£     ±Û Á¦ ¸ñ ÀÛ¼ºÀÏ Á¶È¸
80 Å׵θ®¾ø´Â Æ˾÷â 2018/09/18 (È­) 1550
79 Çѱ¹ÀÇ ÁÖ¿äµµ½Ã À§µµ, °æµµ 2018/09/18 (È­) 1139
78 MySQL ¹é¾÷°ú º¹±¸ : mysqldump, mysqladmin 2018/09/18 (È­) 1069
77 ±¸±ÛÀÌ ¸»ÇÏ´Â SEO, °Ë»ö¿£ÁøÃÖÀûÈ­ ¹æ¹ý 6°¡Áö 2018/09/18 (È­) 1986
76 div °¡¿îµ¥ Á¤·Ä 2018/09/18 (È­) 1010
75 ºÎÆ®½ºÆ®·¦ ¸Þ´º 2018/01/02 (È­) 1320
74 bootstap button menu1 2018/01/02 (È­) 1737
73 ¾ÆÅè ¿¡µðÅÍ ´ÜÃàÅ° ¸ðÀ½ 2017/11/23 (¸ñ) 2289
72 PHP ¹®¹ý 2014/07/25 (±Ý) 2514
71 ¸ÞŸÅÂ±× ¼Ó¼º Á¤¸® 2014/01/31 (±Ý) 2404
70 border-collapse´Â Å×ÀÌºí ¶Ç´Â ¼¿ÀÇ Å׵θ®¼± Ç¥½Ã¹æ¹ýÀ» ÁöÁ¤ÇÏ´Â ¼Ó¼ºÀÔ´Ï´Ù. 2013/10/17 (¸ñ) 2157
69 Áöµµ.ÁÂÇ¥.ÁÖ¼Ò ¸¸µå´Â ±¸±ÛÁöµµ 2013/10/09 (¼ö) 2463
68 css ¼¼·Î¸Þ´º(menu) 2013/10/02 (¼ö) 2534
67 css with jquery ¸Þ´º 2013/09/10 (È­) 1927
66 css ¸Þ´º 2013/09/10 (È­) 1965
65 Fluid Navigation CSS & jQuery(¸Þ´º) 2013/09/10 (È­) 2078
64 CSS Vertical Menu 2013/08/04 (ÀÏ) 2393
63 Navbar ...¸Þ´º 2013/07/31 (¼ö) 2083
62 ±¸±Û, ¹ÙÀ̵Πµî ÇØ¿Ü °Ë»ö¿£Áø »çÀÌÆ®µî·Ï, Áß¿äÇÑ °ÍÀº? 2013/07/21 (ÀÏ) 2338
61 InfoWindow ÀÚµ¿ ¶ç¿ì±â - v3 2013/07/19 (±Ý) 2831
60 Google maps V2 - sidebar list + category + color icons.........2 2013/07/19 (±Ý) 2276
59 ±¸±ÛÁöµµ¿¡ Áö¸íÀ̸§ Ãß°¡ (ÅؽºÆ® Çü) 2013/07/15 (¿ù) 2264
58 Google maps V3 - sidebar list + category + color icons.........3 2013/07/15 (¿ù) 2920
57 text label google maps v3 2013/07/14 (ÀÏ) 2422
56 ±¸±ÛÁöµµ ÁÂÇ¥ ã±â 2013/07/14 (ÀÏ) 2785
55 BING °Ë»ö°ü·Ã ¾ÆÀÌÇÇ ¸ðÀ½ 2013/06/25 (È­) 1926
54 ±¸±Û ÁÂÇ¥(À§µµ. °æµµ)°ªÀ» ¸¶¿ì½º Ŭ¸¯À¸·Î ãÀ» ¼ö ÀÖ½À´Ï´Ù. 2013/06/13 (¸ñ) 4598
53 ¿©·¯ °Ë»ö¿£Áø¿¡ »çÀÌÆ®¸Ê Á¦ÃâÇϱâ 2013/06/11 (È­) 2518
52 GoogleÀÇ À妽º³ª ·©Å· µî¿¡ °üÇÑ 10ÀÇ ¿ÀÇظ¦ Google °ø½Ä 2013/06/11 (È­) 2219
51 ¾ßÈÄ/ºù¿¡¼­ À妽Ì/Å©·Ñ¸µÀÌ ¾ÈµÇ´Â ¹®Á¦ ÇØ°á 2013/06/11 (È­) 2280
123

 

 

 

Àå¹Ù±¸´Ï 0
»óÇ°º¸°üÇÔ 0
¿À´Ãº»¸ñ·Ï 0
°è»ê±â
Æ÷Åа˻ö
ȸ»ç¼Ò°³ £ü  ±¤°í¹®ÀÇ £ü  Á¦ÈÞ¹®ÀÇ £ü  ÀÌ¿ë¾à°ü £ü  û¼Ò³â º¸È£Á¤Ã¥ £ü  °³ÀÎÁ¤º¸ Ãë±Þ¹æħ £ü  °í°´¼¾ÅÍ £ü  »çÀÌÆ®¸Ê
ÁÖ¼Ò : ¼­¿ïƯº°½Ã ¼ºµ¿±¸ ¿ë´ä25±æ 15-1(¿ë´äµ¿) | »óÈ£ : ¿ÃÆ÷¼ÒÇÁÆ®(allfor.kr) | ´ëÇ¥ÀÚ:±è¿µ±æ | ¾÷Å : ¼­ºñ½º.¼Ò¸Å | Á¾¸ñ : ȨÆäÀÌÁöÁ¦ÀÛ. ¼Ö·ç¼Ç°³¹ß. Åë½ÅÆǸŠE-MAIL : admin@allfor.kr | ¢Ï : 070-8116-9964 | 010-5711-7987 | »ç¾÷ÀÚµî·Ï¹øÈ£ : 263-46-00104 | °³ÀÎÁ¤º¸°ü¸® Ã¥ÀÓÀÚ : ±è¿µ±æ