0

緯度と経度を含む気象測定値を含むXMLファイルがあります。与えられた緯度と経度に対応する都市をJavascriptで見つけたいです。どうすればいいですか?

あなたの答えをありがとう

4

1 に答える 1

1
// To initialisation Map and GeoCoder
var geocoder = new google.maps.Geocoder();
var infowindow = new google.maps.InfoWindow(); 
var marker,map;
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();

 directionsDisplay = new google.maps.DirectionsRenderer();
            var chicago = new google.maps.LatLng(41.850033, -87.6500523);
            var mapOptions = {
                zoom: 6,
                mapTypeId: google.maps.MapTypeId.ROADMAP,
                center: chicago
            }

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

// It is called Reverse Geocoding

      var latlng = new google.maps.LatLng(41.850033, -87.6500523);
        geocoder.geocode({'latLng': latlng}, function(results, status) {
          if (status == google.maps.GeocoderStatus.OK) {
            if (results[1]) {
              map.setZoom(11);
              marker = new google.maps.Marker({
                  position: latlng,
                  map: map
              });
              infowindow.setContent(results[1].formatted_address);
              infowindow.open(map, marker);
            } else {
              alert('No results found');
            }
          } else {
            alert('Geocoder failed due to: ' + status);
          }
于 2012-12-14T10:08:58.567 に答える