Как сделать так, чтобы колесо прогресса отображалось только до тех пор, пока не будут нанесены все маркеры? Есть около 50 адресов, через которые проходит каждая функция, и геокодирование и графики в качестве маркеров, и мне нужно показывать колесо прогресса только до тех пор, пока не будут построены все из них, а затем скрыть колесо прогресса и показать карту со всеми создателями.
var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(42.095287, -79.3185139);
var myOptions = {
maxZoom: 14,
zoom: 9,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
};
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
createOverlay();
}
function codeAddress() {
var infowindow = new google.maps.InfoWindow({});
$('.LocationAddress').each(function() {
var addy = $(this).text();
geocoder.geocode( { 'address': addy}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
position: results[0].geometry.location,
map: map,
title:addy,
});
//Adding a click event to the marker
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent('<div id=\"infowindow\" style=" height:100px;>'
+'<div id=\"LeftInfo\">'+ "Hello World!"
+'</div>'+'</div>');
infowindow.open(map, this);
});
}
});//Geocoder END
});
}
subOverlay.prototype = new google.maps.OverlayView();
//constructor for subOverlay
function subOverlay(bounds, image, map) {
// Now initialize all properties.
this.bounds_ = bounds;
this.image_ = image;
this.map_ = map;
this.div_=null;
// Explicitly call setMap() on this overlay
this.setMap(map);
}
//Adding elements to overlay
subOverlay.prototype.onAdd = function() {
// Create the DIV and set some basic attributes.
var div = document.createElement('DIV');
div.style.borderStyle = "none";
div.style.borderWidth = "0px";
div.style.position = "absolute";
var img = document.createElement("img");
img.src = this.image_;
img.style.width = "50px";
img.style.height = "50px";
div.appendChild(img);
// Set the overlay's div_ property to this DIV
this.div_ = div;
// We add an overlay to a map via one of the map's panes.
// We'll add this overlay to the overlayImage pane.
var panes = this.getPanes();
panes.overlayImage.appendChild(div);
}
//drawing overlay on map
subOverlay.prototype.draw = function() {
var overlayProjection = this.getProjection();
var sw = overlayProjection.fromLatLngToDivPixel(this.bounds_.getSouthWest());
var ne = overlayProjection.fromLatLngToDivPixel(this.bounds_.getNorthEast());
// Resize the image's DIV to fit the indicated dimensions.
var div = this.div_;
div.style.left = sw.x + 'px';
div.style.top = ne.y + 'px';
div.style.width = (ne.x - sw.x) + 'px';
div.style.height = (sw.y - ne.y) + 'px';
}
//function create overlay
function createOverlay()
{
var swBound = new google.maps.LatLng(14, -14);
var neBound = new google.maps.LatLng(14, -14);
var bounds = new google.maps.LatLngBounds(swBound, neBound);
// Photograph courtesy of the U.S. Geological Survey
var srcImage = 'http://i276.photobucket.com/albums/kk35/cat_being/GIF%20Movie%20Gear/th_progress_wheel.gif';
overlay = new subOverlay(bounds, srcImage, map);
}