I added a google Map in asp.net application. But running the application, sometimes the Map displayed and sometimes too it doesn't display. I can't find the problem causing that malfunctioning of the application.
Here is the source code :
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
<script type="text/javascript">
var markers = [
<asp:Repeater ID="rptMarkers" runat="server">
<ItemTemplate>
{
"Network": '<%# Eval("Network") %>',
"lat": '<%# Eval("GPSLat") %>',
"lng": '<%# Eval("GPSLong") %>',
"Localite": '<%# Eval("Localite") %>'
}
</ItemTemplate>
<SeparatorTemplate>,
</SeparatorTemplate>
</asp:Repeater>];
</script>
<script type="text/javascript">
window.onload = function () {
var mapOptions = {
center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP,
};
var infoWindow = new google.maps.InfoWindow();
var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
for (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.Network
});
(function (marker, data) {
google.maps.event.addListener(marker, "click", function (e) {
infoWindow.setContent('<b>Reseau:</b> ' + data.Network + '<br/> <b>Localite:</b>' + data.Localite);
infoWindow.open(map, marker);
});
})(marker, data);
}
}
</script>
This is the method that bind the repeater from from the web service method:
MediaWayBackEndService.BMBackEndServiceClient backEndService = new MediaWayBackEndService.BMBackEndServiceClient("BasicHttpBinding_IBMBackEndService");
rptMarkers.DataSource = backEndService.GetKilometricNetwork(network, value).Tables[0];
rptMarkers.DataBind();
This is the output of the application when it works fine and when it does not work fine.
Localhost liks cant be opend from other users!
Based on the console, i have found 1 errors:
Google Maps API warning: SensorNotRequired: https://developers.google.com/maps/documentation/javascript/error-messages

