Once you help me with show google map with markers and it worked perfect till yesterday. But yesterday map stopped showing.
If field Company _Name has apostrophe, map will not showing.
my markers has name "Pawloski's Auto Repair". Pawlowski's has apostrophe.
Uncaught SyntaxError: Unexpected identifier pagTestWithMap.aspx:59 Uncaught ReferenceError: markers is not defined at BindMarkers (pagTestWithMap.aspx:59)
This is code what I have:
<%@ Register Assembly="DevExpress.Web.v21.1, Version=21.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.XtraCharts.v21.1, Version=21.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.XtraCharts" TagPrefix="dx" %>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=API_KEY"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
var markers = [
<asp:Repeater ID="rptMarkers" runat="server">
<ItemTemplate>
{
"title": '<%# Eval("Name") %>',
"lat": '<%# Eval("Latitude") %>',
"lng": '<%# Eval("Longitude") %>',
"description": '<%# Eval("Description") %>'
}
</ItemTemplate>
<SeparatorTemplate>
,
</SeparatorTemplate>
</asp:Repeater >
];
</script>
<script type="text/javascript">
$(function () {
//BindMarkers();
setTimeout(BindMarkers, 1000);
setInterval(function () { BindMarkers() }, 1200000);
});
//window.onload = function () {
function BindMarkers() {
var infoWindow = new google.maps.InfoWindow();
var map = new google.maps.Map(document.getElementById("dvMap"), {
//center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
mapTypeId: google.maps.MapTypeId.ROADMAP
});
//Create LatLngBounds object.
var latlngbounds = new google.maps.LatLngBounds();
for (var i = 0; i < markers.length; i++) {
var data = markers[i]
var myLatlng = new google.maps.LatLng(data.lat, data.lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: data.title
});
(function (marker, data) {
google.maps.event.addListener(marker, "click", function (e) {
infoWindow.setContent("<div style = 'width:200px;min-height:40px'>" + data.description + "</div>");
infoWindow.open(map, marker);
});
})(marker, data);
latlngbounds.extend(marker.position);
}
map.setCenter(latlngbounds.getCenter());
map.fitBounds(latlngbounds);
}
</script>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div id="dvMap" style="border: 1px solid; padding: 0px; width: 900px; height: 640px; resize: both; overflow: auto;">
</div>
</form>
</body>
</html>
Any idea what happens?
Thanks, Alex