한국어

Google API 공부

오늘 :
1,117 / 19,930
어제 :
1,330 / 22,667
전체 :
3,153,919 / 152,123,118


SubKorea 검색
모든 웹사이트 검색

Open API 공부

Naver, Daum, Google Open API

추천 수 : 15 / 0
조회 수 : 2317
2007.11.30 (13:56:44)


http://www.subkorea.com/api/google/MapsAPI/geocoding-extraction.htm위치 검색창을 지도 바깥에, 주소록 표시

<!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" xmlns:v="urn:schemas-microsoft-com:vml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Google Maps JavaScript API Example:         Extraction of Geocoding Data</title>
    <script src="http://maps.google.com/maps?file=api&v=2.x&key=abc...xyz"
            type="text/javascript"></script>
    <script type="text/javascript">

    var map;
    var geocoder;

    function initialize() {
      map = new GMap2(document.getElementById("map_canvas"));
      map.setCenter(new GLatLng(34, 0), 1);
      geocoder = new GClientGeocoder();
    }

    // addAddressToMap() is called when the geocoder returns an
    // answer.  It adds a marker to the map with an open info window
    // showing the nicely formatted version of the address and the country code.
    function addAddressToMap(response) {
      map.clearOverlays();
      if (!response || response.Status.code != 200) {
        alert("Sorry, we were unable to geocode that address");
      } else {
        place = response.Placemark[0];
        point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
        marker = new GMarker(point);
        map.addOverlay(marker);
        marker.openInfoWindowHtml(place.address + '<br>' +
          '<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode);
      }
    }

    // showLocation() is called when you click on the Search button
    // in the form.  It geocodes the address entered into the form
    // and adds a marker to the map at that location.
    function showLocation() {
      var address = document.forms[0].q.value;
      geocoder.getLocations(address, addAddressToMap);
    }

   // findLocation() is used to enter the sample addresses into the form.
    function findLocation(address) {
      document.forms[0].q.value = address;
      showLocation();
    }
    </script>
  </head>

  <body onload="initialize()">

    <!-- Creates a simple input box where you can enter an address
         and a Search button that submits the form. //-->
    <form action="#" onsubmit="showLocation(); return false;">
      <p>
        <b>Search for an address:</b>
        <input type="text" name="q" value="" class="address_input" size="40" />
        <input type="submit" name="find" value="Search" />
      </p>
    </form>
    <div id="map_canvas" style="width: 500px; height: 300px"></div>

   <!-- Sample addresses //-->
   <p><b>Try these:</b><br />

   <a href="javascript:void(0)"
     onclick="findLocation('1600 amphitheatre mountain view ca');return false;">1600
     amphitheatre mountain view ca</a><br />

   <a href="javascript:void(0)"
     onclick="findLocation('1 Telegraph Hill Blvd, San Francisco, CA, USA');return false;">1
     Telegraph Hill Blvd, San Francisco, CA, <b>USA</b></a><br />

   <a href="javascript:void(0)"
     onclick="findLocation('4141 Avenue Pierre-De-Coubertin, Montréal, QC, Canada');return false;">4144
     Avenue Pierre-De-Coubertin, Montréal, <b>Canada</b></a><br />

   <a href="javascript:void(0)"
     onclick="findLocation('Champ de Mars 75007 Paris, France');return false;">Champ
     de Mars 75007 Paris, <b>France</b></a><br />

   <a href="javascript:void(0)"
     onclick="findLocation('Piazza del Colosseo, Roma, Italia');return false;">Piazza
     del Colosseo, Roma, <b>Italia</b></a><br />

   <a href="javascript:void(0)"
     onclick="findLocation('Domkloster 3,  50667 Köln, Deutschland');return false;">Domkloster
     3,  50667 Köln, <b>Deutschland</b></a><br />

   <a href="javascript:void(0)"
     onclick="findLocation('Plaza de la Virgen de los Reyes, 41920, Sevilla, España');return false;">Plaza
     de la Virgen de los Reyes, 41920, Sevilla, <b>España</b></a><br />

   <a href="javascript:void(0)"
     onclick="findLocation('123 Main St, Googleville');return false;">
     123 Main St, <b>Googleville</b></a>
  </p>
  </body>
</html>

번호 제목 닉네임 등록일 조회 추천
52 marker-scroll 첨부 파일
cyber
2007-12-03 3927 20
51 directions-advanced 첨부 파일
cyber
2007-11-30 3658 23
50 directions-simple 첨부 파일
cyber
2007-11-30 3603 17
49 trafficOverlay 첨부 파일
cyber
2007-11-30 3168 33
48 geo-xml 첨부 파일
cyber
2007-11-30 3364 11
47 geoxml-kml 첨부 파일
cyber
2007-11-30 3563 11
46 geoxml-rss 첨부 파일
cyber
2007-11-30 3294 14
45 geocoding-cache 첨부 파일
cyber
2007-11-30 3627 21
Selected geocoding-extraction 첨부 파일
cyber
2007-11-30 2317 15
43 geocoding-simple 첨부 파일
cyber
2007-11-30 3674 12
Tag List