2

php と sql に接続されたマップを作成しようとしています。私の意図は「インフォボックス」をカスタマイズすることですが、解決策が見つかりません。これは.jsにあります。助けていただければ幸いです。ありがとうございました。

  var map;

  function initialize() {
    var myOptions = {
      zoom: 15,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById('map'),
        myOptions);

    // Try HTML5 geolocation
    if(navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function(position)  {
        var pos = new google.maps.LatLng(position.coords.latitude,
                                         position.coords.longitude);

        var marker = new google.maps.Marker({
          map: map,
          position: pos,
          icon:'images/bar.png',
          animation: google.maps.Animation.DROP,
          title: 'Location found using HTML5.'
        });

  var infoWindow = new google.maps.InfoWindow;


  // Change this depending on the name of your PHP file
  downloadUrl("http://adricas.org/onferrol/mapa/phpsqlajax_genxml.php", function(data) {
    var xml = data.responseXML;
    var markers = xml.documentElement.getElementsByTagName("marker");
    for (var i = 0; i < markers.length; i++) {
      var name = markers[i].getAttribute("name");
      var address = markers[i].getAttribute("address");
      var citystate = markers[i].getAttribute("citystate");
      var phone = markers[i].getAttribute("phone");
      var type = markers[i].getAttribute("type");
      var info = markers[i].getAttribute("info");
      var website = markers[i].getAttribute("website");
      var point = new google.maps.LatLng(
          parseFloat(markers[i].getAttribute("lat")),
          parseFloat(markers[i].getAttribute("lng")));
      var html = "<b>" + name +"</b> <br/>" 
      + info + 
      "</br> <a href="+website+">Zoom out</a>" ;

      var icon = customIcons[type] || {};
      var marker = new google.maps.Marker({
        map: map,
        position: point,
        icon: icon.icon,
        shadow: icon.shadow
      });
      bindInfoWindow(marker, map, infoWindow, html);
    }
  });           


        map.setCenter(pos);
      }, function() {
        handleNoGeolocation(true);
      });
    } else {
      // Browser doesn't support Geolocation
      handleNoGeolocation(false);
    }
  }


  function handleNoGeolocation(errorFlag) {
    if (errorFlag) {
      var content = 'Error: The Geolocation service failed.';
    } else {
      var content = 'Error: Your browser doesn\'t support geolocation.';
    }


    var options = {
      map: map,
      position: new google.maps.LatLng(60, 105),
      content: content
    };

    var infowindow = new google.maps.InfoWindow(options);
    map.setCenter(options.position);

  }

// 「その他」の DB リスト機能に関連する追加機能

function bindInfoWindow(marker, map, infoWindow, html) {
  google.maps.event.addListener(marker, 'click', function() {
    infoWindow.setContent(html);
    infoWindow.open(map, marker);
  });
}

function downloadUrl(url, callback) {
  var request = window.ActiveXObject ?
      new ActiveXObject('Microsoft.XMLHTTP') :
      new XMLHttpRequest;

  request.onreadystatechange = function() {
    if (request.readyState == 4) {
      request.onreadystatechange = doNothing;
      callback(request, request.status);
    }
  };

  request.open('GET', url, true);
  request.send(null);
}

function doNothing() {}   


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

0 に答える 0