Uncaught TypeError: Cannot read property of undefined - Google Maps Javascript API -
i developping web app using google maps javascript api. worked fine until few hours ago, when got these errors :
`uncaught typeerror: cannot read property '15' of undefined` `uncaught typeerror: cannot read property '9' of undefined`
here html code :
<!doctype html> <html> <head> <title>application</title> <meta name="viewport" content="initial-scale=1.0"> <meta charset="utf-8"> <style> html, body { height: 100%; margin: 0; padding: 0; } </style> <script src="https://d3js.org/d3.v4.js"></script> <script type="text/javascript" src="main.js"></script> <script type="text/javascript" src="script.js"></script> <script src="https://maps.googleapis.com/maps/api/js?key=my_key&callback=initmap" async defer></script> </head> <body> <h1 align="center">notre super indicateur</h1> <div id="map" style="width:1000px; height:800px; margin-left:auto; margin-right:auto;"></div> </body> </html>
and here script.js file :
function initmap() { var tab = arraydata; var map = new google.maps.map(document.getelementbyid('map'), { center: {lat: 48.856583, lng: 2.337341}, zoom: 12 }); map.data.loadgeojson('some geojson file'); map.data.setstyle(function(feature) { var color; var nb = feature.getproperty("c_qu"); if (tab[nb-1].index < 0.3) { color = "red"; } else if (tab[nb-1].index < 0.6) { color = "orange"; } else { color = "green"; } return /** @type {google.maps.data.styleoptions} */({ fillcolor: color, strokecolor: "grey", strokeweight: 2 }); }); }
note : arraydata defined in main.js file
this weird : error said in script.js file, when update error stays @ same line. weirder fact once in 15 or 20 times, works (and code on github pages , works fine).
could me this? thank ! tom.
Comments
Post a Comment