私のウェブサイト www.procomport.com は、Google Chrome と Firefox でのみ動作します。
私がすべてのコードを含む質問を投稿するたびに、誰もがコードを投稿する必要があると叫び続けます。他に何が欲しいですか!? JS は Chrome と Firefox で問題なく動作しますが、それ以外は問題ありません。
Javascript
var geocoder;
var map;
var lat1;
var lng1;
var lat2;
var lng2;
var range;
var htmlcard;
var initialLocation;
var measure;
function initialize() {
var siberia = new google.maps.LatLng(34.0522, -118.2428);
var newyork = new google.maps.LatLng(40.69847032728747, -73.9514422416687);
var browserSupportFlag = new Boolean();
var address = document.getElementById("addressForm");
//alert(address.value.trim().length);
//alert(address.value.length);
if (address.value.length <= 2) {
if (navigator.geolocation) {
browserSupportFlag = true;
navigator.geolocation.getCurrentPosition(function (position) {
initialLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
//createMap2(initialLocation);
load(initialLocation);
lat1 = position.coords.latitude;
lng1 = position.coords.longitude;
}, function () {
handleNoGeolocation(browserSupportFlag);
});
}
// Browser doesn't support Geolocation
else {
browserSupportFlag = false;
handleNoGeolocation(browserSupportFlag);
}
function handleNoGeolocation(errorFlag) {
if (errorFlag == true) {
//alert("Failed to find location.");
//createMap(newyork);
load(newyork);
} else {
//alert("Your browser doesn't support geolocation. We've placed you in Los Angeles.");
//createMap(siberia);
load(siberia);
}
}
}
else {
geocoder = new google.maps.Geocoder();
var address = document.getElementById("addressForm").value;
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
load(results[0].geometry.location)
lat1 = results[0].geometry.location.lat();
lng1 = results[0].geometry.location.lng();
}
});
}
}
function load(center) {
range = document.getElementById("distance").value;
if (range == "" || range == 0)
{
range = "200";
}
measure = document.getElementById("measure").value;
if (measure !== "m") {
measure == "km";
}
geocoder = new google.maps.Geocoder();
var mapOptions1 = {
zoom: 12,
center: center,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions1);
var marker = new google.maps.Marker({
map: map,
position: center
});
var professionFilter = document.getElementById("professionFilterValue").value;
//alert(professionFilter);
downloadUrl("xml.php?p=" + professionFilter, function (data) {
var xml = data.responseXML; // xml file generated from xml.php
var markers = xml.documentElement.getElementsByTagName("marker"); // parses XML and gets Markers From Data
for (var i = 0; i < markers.length; i++) {
// Sets infoWindow for specific marker
var infoWindow = new google.maps.InfoWindow({ maxwidth: 350 });
google.maps.event.addListener(map, "click", function () { infoWindow.close(); });
//=========================================================================================
// Sets Marker Attributes an Location
lat2 = markers[i].getAttribute("lat");
lng2 = markers[i].getAttribute("lng");
var distance = getDistance(lat1, lng1, lat2, lng2)
var display_name = markers[i].getAttribute('dname')
var card = markers[i].getAttribute('card')
var htmlCard = decodeURIComponent(card)
if (getDistance(lat1, lng1, lat2, lng2) < range) {
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var html = htmlCard
var icon = "https://www.procomport.com/site/www/images/computericon.png"
var marker = new google.maps.Marker({
map: map,
position: point,
icon: "/site/www/images/computericon.png",
shadow: icon.shadow,
title: name
});
bindInfoWindow(marker, map, infoWindow, html);
}
}
//=========================================================================================
});
}
function bindInfoWindow(marker, map, infoWindow, html) {
google.maps.event.addListener(marker, 'click', function () {
setTimeout(function () { infoWindow.setContent(html); }, '1000');
setTimeout(function () { infoWindow.open(map, marker); }, '1000');
setTimeout(function () { infoWindow.close(); }, '5000');
});
}
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function () {
if (request.readyState == 4 && request.status == 200) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
function doNothing() { }
function getDistance(lat11, lon11, lat22, lon22) {
var R;
if (measure == "km") {
R = 6371;
}
else {
R = 3959;
}
// km (change this constant to get miles)
var dLat = (lat22 - lat11) * Math.PI / 180;
var dLon = (lon22 - lon11) * Math.PI / 180;
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) *
Math.sin(dLon / 2) * Math.sin(dLon / 2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
var d = R * c;
if (d > 1) return Math.round(d);
else if (d <= 1) return Math.round(d * 1000);
return d;
}
何が間違っているのか本当に頭がおかしくなったように、言われたとおりにW3バリデーターを実行し、多くのエラーを修正しました(メタタグを除く) バリデーターの結果
この問題を正確に診断するには、他にどのようなコードが必要ですか?
Internet Explorer コンソール出力。
HTML1114: Codepage iso-8859-1 from (META tag) overrides conflicting codepage windows-1252 from (META tag)
map.php
HTML1514: Extra "<body>" tag found. Only one "<body>" tag should exist per document.
map.php, line 154 character 1
HTML1522: Invalid end tag: "</br>". Use "<br>" or "<br/>" instead.
map.php, line 322 character 9
HTML1522: Invalid end tag: "</br>". Use "<br>" or "<br/>" instead.
map.php, line 524 character 164
HTML1522: Invalid end tag: "</br>". Use "<br>" or "<br/>" instead.
map.php, line 524 character 343
HTML1522: Invalid end tag: "</br>". Use "<br>" or "<br/>" instead.
map.php, line 525 character 120
Invalid App Id: Must be a number or numeric string representing the application id.
アップデート:
すべての IE エラーを修正 - まだマーカーがない
更新 2:
ブラウザのキャッシュをクリアしてページをリロードするたびに、ある程度の進歩があり、正常に機能します。
更新 3:
マップはSafariでも読み込まれません