簡體   English   中英

谷歌地圖標記出現在Chrome中,但不出現在Firefox或IE中

[英]Google Map Markers Appear in Chrome but not in Firefox or IE

我是設計www.localenvironmentsurvey.com的新手編碼員。 主頁上的地圖顯示已填寫調查的每個人的位置,地圖可在Chrome中使用。 但是,沒有任何標記出現在Firefox或IE中。

首先,我的index.html文件中的相關代碼:

        <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">

function load() {
  var map = new google.maps.Map(document.getElementById("map"), {
    center: new google.maps.LatLng(44.9672, -103.7716),
    zoom: 3,
  });
  var infoWindow = new google.maps.InfoWindow;

  downloadUrl("phpsqlajax_genxml2.php", function(data) {
    var xml = data.responseXML;
    var survey = xml.documentElement.getElementsByTagName("marker");
    for (var i = 0; i < survey.length; i++) {
      var govname = survey[i].getAttribute("govname");
      var state = survey[i].getAttribute("state");
      var govtype = survey[i].getAttribute("govtype");
      var point = new google.maps.LatLng(
          parseFloat(survey[i].getAttribute("lat")),
          parseFloat(survey[i].getAttribute("lng")));
      var html = "<b>" + govname + "</b> <br/>" + state;
      var marker = new google.maps.Marker({
        map: map,
        position: point,
      });
      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() {}

接下來,這是phpsqlajax_genxml2.php文件中的代碼:

<?php
require("les.php");

function parseToXML($htmlStr) 
{ 
$xmlStr=str_replace('<','&lt;',$htmlStr); 
$xmlStr=str_replace('>','&gt;',$xmlStr); 
$xmlStr=str_replace('"','&quot;',$xmlStr); 
$xmlStr=str_replace("'",'&#39;',$xmlStr); 
$xmlStr=str_replace("&",'&amp;',$xmlStr); 
return $xmlStr; 
} 

// Opens a connection to a MySQL server
$connection=mysql_connect ('db', $username_les, $password_les);
if (!$connection) {
die('Not connected : ' . mysql_error());
}

// Set the active MySQL database
$db_selected = mysql_select_db($database_les, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}

// Select all the rows in the survey table
$query = "SELECT * FROM survey WHERE 1";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}

header("Content-type: text/xml");

// Start XML file, echo parent node
echo '<survey>';

// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
echo '<marker ';
echo 'govname="' . parseToXML($row['govname']) . '" ';
echo 'state="' . parseToXML($row['state']) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lng'] . '" ';
echo 'govtype="' . $row['govtype'] . '" ';
echo '/>';
}

// End XML file
echo '</survey>';

?>

關於如何讓這張地圖在Firefox和IE中運行的任何建議都將深深地,非常感謝!

實際上它已知錯誤加載標記圖標(圖像)。檢查mozilla支持頁面 。這個問題已在Firefox版本13中修復,我建議切換到最新版本的Firefox並檢查。

謝謝你們倆的幫助和反饋。 碰巧的是,問題完全是另一回事:我需要將此代碼添加到我的“phpsqlajax_genxml2.php”文件中:

$xmlStr = str_replace( 'À', '&#192;', $xmlStr ); 
$xmlStr = str_replace( 'Á', '&#193;', $xmlStr ); 
$xmlStr = str_replace( 'Â', '&#194;', $xmlStr ); 
$xmlStr = str_replace( 'Ã', '&#195;', $xmlStr ); 
$xmlStr = str_replace( 'Ä', '&#196;', $xmlStr ); 
$xmlStr = str_replace( 'Å', '&#197;', $xmlStr ); 
$xmlStr = str_replace( 'Æ', '&#198;', $xmlStr ); 
$xmlStr = str_replace( 'Ç', '&#199;', $xmlStr ); 
$xmlStr = str_replace( 'È', '&#200;', $xmlStr ); 
$xmlStr = str_replace( 'É', '&#201;', $xmlStr ); 
$xmlStr = str_replace( 'Ê', '&#202;', $xmlStr ); 
$xmlStr = str_replace( 'Ë', '&#203;', $xmlStr ); 
$xmlStr = str_replace( 'Ì', '&#204;', $xmlStr ); 
$xmlStr = str_replace( 'Í', '&#205;', $xmlStr ); 
$xmlStr = str_replace( 'Î', '&#206;', $xmlStr ); 
$xmlStr = str_replace( 'Ï', '&#207;', $xmlStr ); 
$xmlStr = str_replace( 'Ð', '&#208;', $xmlStr ); 
$xmlStr = str_replace( 'Ñ', '&#209;', $xmlStr ); 
$xmlStr = str_replace( 'Ò', '&#210;', $xmlStr ); 
$xmlStr = str_replace( 'Ó', '&#211;', $xmlStr ); 
$xmlStr = str_replace( 'Ô', '&#212;', $xmlStr ); 
$xmlStr = str_replace( 'Õ', '&#213;', $xmlStr ); 
$xmlStr = str_replace( 'Ö', '&#214;', $xmlStr ); 
$xmlStr = str_replace( '×', '&#215;', $xmlStr );  
$xmlStr = str_replace( 'Ø', '&#216;', $xmlStr ); 
$xmlStr = str_replace( 'Ù', '&#217;', $xmlStr ); 
$xmlStr = str_replace( 'Ú', '&#218;', $xmlStr ); 
$xmlStr = str_replace( 'Û', '&#219;', $xmlStr ); 
$xmlStr = str_replace( 'Ü', '&#220;', $xmlStr ); 
$xmlStr = str_replace( 'Ý', '&#221;', $xmlStr ); 
$xmlStr = str_replace( 'Þ', '&#222;', $xmlStr ); 
$xmlStr = str_replace( 'ß', '&#223;', $xmlStr ); 
$xmlStr = str_replace( 'à', '&#224;', $xmlStr ); 
$xmlStr = str_replace( 'á', '&#225;', $xmlStr ); 
$xmlStr = str_replace( 'â', '&#226;', $xmlStr ); 
$xmlStr = str_replace( 'ã', '&#227;', $xmlStr ); 
$xmlStr = str_replace( 'ä', '&#228;', $xmlStr ); 
$xmlStr = str_replace( 'å', '&#229;', $xmlStr ); 
$xmlStr = str_replace( 'æ', '&#230;', $xmlStr ); 
$xmlStr = str_replace( 'ç', '&#231;', $xmlStr ); 
$xmlStr = str_replace( 'è', '&#232;', $xmlStr ); 
$xmlStr = str_replace( 'é', '&#233;', $xmlStr ); 
$xmlStr = str_replace( 'ê', '&#234;', $xmlStr ); 
$xmlStr = str_replace( 'ë', '&#235;', $xmlStr ); 
$xmlStr = str_replace( 'ì', '&#236;', $xmlStr ); 
$xmlStr = str_replace( 'í', '&#237;', $xmlStr ); 
$xmlStr = str_replace( 'î', '&#238;', $xmlStr ); 
$xmlStr = str_replace( 'ï', '&#239;', $xmlStr ); 
$xmlStr = str_replace( 'ð', '&#240;', $xmlStr ); 
$xmlStr = str_replace( 'ñ', '&#241;', $xmlStr ); 
$xmlStr = str_replace( 'ò', '&#242;', $xmlStr ); 
$xmlStr = str_replace( 'ó', '&#243;', $xmlStr ); 
$xmlStr = str_replace( 'ô', '&#244;', $xmlStr ); 
$xmlStr = str_replace( 'õ', '&#245;', $xmlStr ); 
$xmlStr = str_replace( 'ö', '&#246;', $xmlStr ); 
$xmlStr = str_replace( '÷', '&#247;', $xmlStr );
$xmlStr = str_replace( 'ø', '&#248;', $xmlStr ); 
$xmlStr = str_replace( 'ù', '&#249;', $xmlStr ); 
$xmlStr = str_replace( 'ú', '&#250;', $xmlStr ); 
$xmlStr = str_replace( 'û', '&#251;', $xmlStr ); 
$xmlStr = str_replace( 'ü', '&#252;', $xmlStr ); 
$xmlStr = str_replace( 'ý', '&#253;', $xmlStr ); 
$xmlStr = str_replace( 'þ', '&#254;', $xmlStr ); 
$xmlStr = str_replace( 'ÿ', '&#255;', $xmlStr ); 

這是因為城市和縣名人員提交的包括超常常撇號和放大器之外的異常字符,我需要將所有這些解析為xml,否則標記將無法在Firefox和IE中加載。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM