1

我有两个谷歌地图页面,第一个是http://www.fishtrends.com/home.html这是用户输入标记详细信息的地方。

然后显示输入到 MySQL DB 中的结果;

<!DOCTYPE html >
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=yes" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Fishtrends Analysis</title>
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript">
    //<![CDATA[

    var customIcons = {
    Bass: {
        icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png'
      },
    Cod: {
        icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png'
      },
      Gurnard: {
        icon: 'http://labs.google.com/ridefinder/images/mm_20_orange.png'
      },
      Flatty: {
        icon: 'http://labs.google.com/ridefinder/images/mm_20_green.png'
      },
      Mackerel: {
        icon: 'http://labs.google.com/ridefinder/images/mm_20_grey.png'
      },
      Whiting: {
        icon: 'http://labs.google.com/ridefinder/images/mm_20_white.png'
      },
      Pollack: {
        icon: 'http://labs.google.com/ridefinder/images/mm_20_black.png'
      },
      Wrasse: {
        icon: 'http://labs.google.com/ridefinder/images/mm_20_purple.png'
      },
      Garfish: {
        icon: 'http://labs.google.com/ridefinder/images/mm_20_brown.png'
      },
      Blank: {
        icon: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
       },
      };

     function load() {
      var map = new google.maps.Map(document.getElementById("map"), {
        center: new google.maps.LatLng(50.727763, -1.878662),
        zoom: 7,
        mapTypeId: 'roadmap'
      });
      var infoWindow = new google.maps.InfoWindow;

      // Change this depending on the name of your PHP file
      downloadUrl("phpsqldom.php", function(data) {
        var xml = data.responseXML;
        var markers = xml.documentElement.getElementsByTagName("marker");
        for (var i = 0; i < markers.length; i++) {
          var fishname = markers[i].getAttribute("fishspecies");         
          var fishbait = markers[i].getAttribute("bait");
          var caughttime = markers[i].getAttribute("time");
          var point = new google.maps.LatLng(
              parseFloat(markers[i].getAttribute("lat")),
              parseFloat(markers[i].getAttribute("lng")));
          var html = "<b>" + fishname + "</b> <br/>" + fishbait + caughttime;
          var icon = customIcons[fishname] || {};
          var marker = new google.maps.Marker({
            map: map,
            position: point,
            icon: icon.icon
          });
          bindInfoWindow(marker, map, infoWindow, html);
        }
      });
    }

    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() {}

    //]]>

  </script>

  </head>

  <body onload="load()">
    <div id="map-canvas" style="width: 1500px; height: 600px"></div>
  </body> 

我怎样才能在同一个功能页面上获得这两个?

4

0 回答 0