Naver, Daum, Google Open API
글 수 52
cyber
http://www.subkorea.com/api/google/MapsAPI/marker-tabbed.html마크별로 다른 tab(1-4개 설명문) 있음
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Google Maps</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=abc...xyz" type="text/javascript"></script>
</head>
<body onunload="GUnload()">
<!-- the div where the map will be displayed -->
<div id="map" style="width: 550px; height: 450px"></div>
<a href="basic10.htm">Back to the tutorial page</a>
<!-- fail nicely if the browser has no Javascript -->
<noscript><b>JavaScript must be enabled in order for you to use Google Maps.</b>
However, it seems JavaScript is either disabled or not supported by your browser.
To view Google Maps, enable JavaScript by changing your browser options, and then
try again.
</noscript>
<script type="text/javascript">
//<![CDATA[
// Check to see if this browser can run the Google API
if (GBrowserIsCompatible()) {
// ==================================================
// A function to create a tabbed marker and set up the event window
// This version accepts a variable number of tabs, passed in the arrays htmls[] and labels[]
function createTabbedMarker(point,htmls,labels) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
// adjust the width so that the info window is large enough for this many tabs
if (htmls.length > 2) {
htmls[0] = '<div style="width:'+htmls.length*88+'px">' + htmls[0] + '</div>';
}
var tabs = [];
for (var i=0; i<htmls.length; i++) {
tabs.push(new GInfoWindowTab(labels[i],htmls[i]));
}
marker.openInfoWindowTabsHtml(tabs);
});
return marker;
}
// ==================================================
// Display the map, with some controls and set the initial location
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(43.907787,-79.359741), 9);
// ==================================================
// Set up the tabbed markers
var point = new GLatLng(43.82589,-79.10040);
var marker = createTabbedMarker(point, ["Tab 1 contents", "Tab 2 contents","Tab 3 contents"],["One","Two","Three"]);
map.addOverlay(marker);
var point = new GLatLng(43.72589,-79.8);
var marker = createTabbedMarker(point, ["Tab 1 contents", "Tab 2 contents","Tab 3 contents","Tab 4 contents"],["One","Two","Three","Four"]);
map.addOverlay(marker);
var point = new GLatLng(43.65654,-79.90138);
var marker = createTabbedMarker(point, ["is the time for all good men<br>to come to the aid of the party", "a dangerous temptation comes to us<br>in gay, fine colours"],["Now", "Many"]);
map.addOverlay(marker);
var point = new GLatLng(43.8,-79.3);
var marker = createTabbedMarker(point, ["This marker has no tabs"],["Nothing"]);
map.addOverlay(marker);
}
// display a warning if the browser was not compatible
else {
alert("Sorry, the Google Maps API is not compatible with this browser");
}
// This Javascript is based on code provided by the
// Blackpool Community Church Javascript Team
// http://www.commchurch.freeserve.co.uk/
// http://econym.googlepages.com/index.htm
//]]>
</script>
</body>
</html>
http://subkorea.com/xe/84631
(*.225.54.140)
|