Я понятия не имею, почему он продолжает говорить, что Google не определен.Кто-нибудь знает проблему?
Я уже пытался переместить скрипт в голову, и все, но здесь по-прежнему бесполезно.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 2,
center: new google.maps.LatLng(2.8,-187.3),
mapTypeId: 'terrain'
});
}
// Loop through the results array and place a marker for each
// set of coordinates.
function loop() {
var lati=JSON.parse(localStorage.getItem("lat2"))
console.log("Hi")
console.log(lati)
for (var i = 0; i < lati.length; i++) {
var coords = lati[i]
var latLng = {lat: (coords[0]), lng:(coords[1])};
var marker = new google.maps.Marker({
position: latLng,
map: map
});
}
}
loop()
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=THEAPIKEY=initMap">
</script>
</body>
</html>
Я хотел, чтобы он зацикливался на том, что есть в моемлокальное хранилище