<div id="map"></div>
<!-- Replace the value of the key parameter with your own API key. -->
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyARbDtBazTZTGrmxsIuCJHAQLdsPiAsXkw&libraries=places&callback=initMap" async defer></script>
CSS
/* 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;
}
JavaScript
// This example requires the Places library. Include the libraries=places
// parameter when you first load the API. For example:
// <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places">
var myList = ['','Canon Kontor ','DNB','Handelsbanken','Rica Eiendom','Storebrand','Radisson Hotels Norway','Caverion','Color Line','DNV GL','SAS','Select Service Partner','Gress-Gruppen','NHG Management','Hurtigruten','Compass Group','Radisson Blu Scandinavia Hotel','Park Inn Oslo Airport','Park Inn Oslo','Radisson Blu Airport Hotel','Radisson Blu Hotel Alna','Radisson Blu Plaza Hotel','Stamina Helse'];
var i = 1;
var map;
var service;
var infowindow;
var k=0;
function initMap() {
var mapCenter = new google.maps.LatLng(-33.8617374,151.2021291);
map = new google.maps.Map(document.getElementById('map'), {
center: mapCenter,
zoom: 15
});
myLoop();
}
function callback(results, status) {
//console.log(results);
if (status == google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
var place = results[i];
console.log(results[i].name+';'+results[i].formatted_address+';'+results[i].geometry.location.lat()+';'+results[i].geometry.location.lng());
}
}
}
// set your counter to 1
function myLoop () { // create a loop function
setTimeout(function () { // call a 3s setTimeout when the loop is called
console.log(myList[i]);
var request = {
query: myList[i],
fields: ['photos', 'formatted_address', 'name', 'rating', 'opening_hours', 'geometry'],
};
service = new google.maps.places.PlacesService(map);
service.findPlaceFromQuery(request, callback); // your code here
i++; // increment the counter
if (i < myList.length) { // if the counter < 10, call the loop function
myLoop(); // .. again which will trigger another
} ...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.