Guest User

Guest User

  • Tech Writer
  • 2.1k
  • 474.2k

Uncaught syntax error handle?

Mar 10 2020 4:06 AM
Hi Team
 
I am using Google Maps API using Javascript, some how my app is throwing this error 'Uncaught Syntax error handle. Could i be missing some javascript libraries to this view, please advice me and help mates.
  1. @{  
  2.     ViewBag.Title = "GoogleMaps";  
  3.     Layout = null;  
  4. }  
  5.   
  6. <!DOCYTPE html>  
  7. <html>  
  8. <head>  
  9.     <meta name="viewport" content="width=device-width"/>  
  10.     <title>eNtsa Office Location</title>  
  11. </head>  
  12. <body>  
  13.     <div id="dvMap" style="width: 500px; height: 500px">  
  14.     </div>  
  15.     <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIz***"></script>  
  16.     <script type="text/javascript">  
  17.         var markers = @Html.Raw(ViewBag.Markers);// Uncaught syntax error handled  
  18.         window.onload = function () {  
  19.             var mapOptions = {  
  20.                 center: new google.maps.LatLng(markers[0].lat, markers[0].lng),  
  21.                 zoom: 8,  
  22.                 mapTypeId: google.maps.MapTypeId.ROADMAP  
  23.             };  
  24.             var infoWindow = new google.maps.InfoWindow();  
  25.             var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);  
  26.             for (i = 0; i < markers.length; i++) {  
  27.                 var data = markers[i]  
  28.                 var myLatlng = new google.maps.LatLng(data.lat, data.lng);  
  29.                 var marker = new google.maps.Marker({  
  30.                     position: myLatlng,  
  31.                     map: map,  
  32.                     title: data.title  
  33.                 });  
  34.                 (function (marker, data) {  
  35.                     google.maps.event.addListener(marker, "click"function (e) {  
  36.                         infoWindow.setContent(data.description);  
  37.                         infoWindow.open(map, marker);  
  38.                     });  
  39.                 })(marker, data);  
  40.             }  
  41.         }  
  42.     </script>  
  43. </body>  
  44.   
  45. </html>  
 

Answers (11)