我需要在googlemaps上显示一些标记。 我已经写了这个部分,我用locationList数组传递数据,但地图不显示我的所有标记。你能帮助我理解我遇到问题的地方吗? 谢谢你的答案。
<asp:Content id="CustomScripts" ContentPlaceHolderID="CustomScript" runat ="server">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var map;
function initialize() {
var mapCanvas = document.getElementById('map-canvas');
var mapOptions = {
center: new google.maps.LatLng(44.837367, 11.029718),
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(mapCanvas, mapOptions);
var temp = locationList
for (var i = 0; i < locationList.length; i++) {
var args = locationList[i].split(",");
var location = new google.maps.LatLng(args[0], args[1])
var marker = new google.maps.Marker({
position: location,
map: map
});
var j = i + 1;
marker.setTitle(message[i].replace(/(<([^>]+)>)/ig, ""));
attachSecretMessage(marker, i);
}
}
google.maps.event.addDomListener(window, 'load', initialize);
function attachSecretMessage(marker, number) {
var infowindow = new google.maps.InfoWindow({
content: message[number],
size: new google.maps.Size(50, 50)
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
}
$(document).ready(function () {
$("#MainContent_time1 , #MainContent_time2").datetimepicker({
dateFormat: 'yy/mm/dd',
timeFormat: 'HH:mm:ss',
pick12HourFormat: false
});
$("#MainContent_time1 , #MainContent_time2").keydown(function (e) {
var charCode = e.which;
if (charCode != 8 && charCode != 46) {
e.preventDefault();
} else {
var id = $(this).attr("id");
$("#" + id).val("");
}
});
});
</script>