我正在为我的网站使用Google地图。它显示几个标记,并将它们全部放在屏幕上。如果'Accept-Language'设置为英语,一切正常。一旦你用其他语言改变'Accept-Language',所有标记就会在地图上变成洗牌。无法弄清楚我做错了什么。
<html>
<head lang="en">
<title>GMaps Test</title>
<meta charset="UTF-8">
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js"></script>
<script language="JavaScript" type="text/javascript">
$(document).ready(function () {
var map;
// List of markers
var all_markers = [];
function map_initialize() {
var mapOptions = {
center: { lat: 57.332332, lng: 34.725238},
zoom: 5,
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL
},
disableDefaultUI: true
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
// Make an array of the LatLng's of the markers to show
var LatLngList = [
{id: "4", pos: new google.maps.LatLng(55,7569492,37,6416684)},
{id: "3", pos: new google.maps.LatLng(40,790278,-73,959722)},
{id: "7", pos: new google.maps.LatLng(37,8099098,-122,497668)},
{id: "1", pos: new google.maps.LatLng(55,7773455,37,6423385)},
];
// Create a new viewpoint bound
var bounds = new google.maps.LatLngBounds();
// For outputting info
var infowindow = new google.maps.InfoWindow();
// Go through each...
for (var i = 0, LtLgLen = LatLngList.length; i < LtLgLen; i++) {
// Adding marker to the map
var marker = new google.maps.Marker({
position: new google.maps.LatLng(LatLngList[i].pos.lat(), LatLngList[i].pos.lng()),
map: map,
icon: "https://www.google.com/intl/en_us/mapfiles/ms/micons/pink-dot.png"
});
// Storing marker in a list
all_markers.push({id: LatLngList[i].id, marker: marker});
// And increase the bounds to take this point
bounds.extend(LatLngList[i].pos);
// Click handler for the marker
google.maps.event.addListener(marker, 'click', (function (marker, i) {
return function () {
infowindow.setContent('Ololo');
infowindow.open(map, marker);
}
})(marker, i));
}
// Fit these bounds to the map
if(LatLngList.length > 0) map.fitBounds(bounds);
};
google.maps.event.addDomListener(window, 'load', map_initialize);
});
</script>
</head>
<body>
<div id="map-canvas" style="height: 100%; width: 100%; padding: 0; margin: 0"></div>
</body>
</html>
答案 0 :(得分:0)
在javascript中,小数分隔符是一个点,但您使用逗号