lazyload google maps
This commit is contained in:
parent
d267b21f41
commit
33cce09096
1 changed files with 82 additions and 69 deletions
|
@ -218,40 +218,37 @@ requires
|
||||||
var config = data;
|
var config = data;
|
||||||
Ox.print('config', config);
|
Ox.print('config', config);
|
||||||
document.title = config.site.name;
|
document.title = config.site.name;
|
||||||
window.google = function() {};
|
loadImages(function() {
|
||||||
$.getScript('http://maps.google.com/maps/api/js?callback=google&sensor=false', function() {
|
that.api.api(function(result) {
|
||||||
loadImages(function() {
|
$.each(result.data.actions, function(i, action) {
|
||||||
that.api.api(function(result) {
|
that.api[action] = function(data, callback) {
|
||||||
$.each(result.data.actions, function(i, action) {
|
if (arguments.length == 1) {
|
||||||
that.api[action] = function(data, callback) {
|
callback = data;
|
||||||
if (arguments.length == 1) {
|
data = {};
|
||||||
callback = data;
|
}
|
||||||
data = {};
|
return Ox.Request.send({
|
||||||
}
|
url: self.options.apiURL,
|
||||||
return Ox.Request.send({
|
data: {
|
||||||
url: self.options.apiURL,
|
action: action,
|
||||||
data: {
|
data: JSON.stringify(data)
|
||||||
action: action,
|
},
|
||||||
data: JSON.stringify(data)
|
callback: callback
|
||||||
},
|
});
|
||||||
callback: callback
|
};
|
||||||
});
|
});
|
||||||
};
|
that.api[self.options.init](getUserData(), function(data) {
|
||||||
});
|
var user = data.data.user;
|
||||||
that.api[self.options.init](getUserData(), function(data) {
|
$(function() {
|
||||||
var user = data.data.user;
|
var $div = $body.find('div');
|
||||||
$(function() {
|
$body.find('img').remove();
|
||||||
var $div = $body.find('div');
|
$div.animate({
|
||||||
$body.find('img').remove();
|
opacity: 0
|
||||||
$div.animate({
|
}, 1000, function() {
|
||||||
opacity: 0
|
$div.remove();
|
||||||
}, 1000, function() {
|
});
|
||||||
$div.remove();
|
callback({
|
||||||
});
|
config: config,
|
||||||
callback({
|
user: user
|
||||||
config: config,
|
|
||||||
user: user
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -7270,40 +7267,56 @@ requires
|
||||||
key_escape: deselectPlace
|
key_escape: deselectPlace
|
||||||
});
|
});
|
||||||
|
|
||||||
$.extend(self, {
|
if (Ox.isUndefined(window.google)) {
|
||||||
geocoder: new google.maps.Geocoder(),
|
window.google = function() {};
|
||||||
selected: -1
|
$.getScript('http://maps.google.com/maps/api/js?callback=google&sensor=false', function() {
|
||||||
});
|
var interval = setInterval(function() {
|
||||||
if (Ox.isObject(self.options.places[0])) {
|
if (!Ox.isUndefined(google.maps)) {
|
||||||
$.each(self.options.places, function(i, place) {
|
clearInterval(interval);
|
||||||
place.bounds = getBounds(),
|
initMap();
|
||||||
place.center = place.bounds.getCenter();
|
}
|
||||||
$.extend(place, {
|
}, 100);
|
||||||
marker: new Marker(place),
|
});
|
||||||
polygon: new Polygon(place)
|
} else {
|
||||||
});
|
initMap();
|
||||||
self.bounds = i == 0 ? getBounds() : self.bounds.union(place.bounds);
|
}
|
||||||
self.options.places[i] = place;
|
|
||||||
function getBounds() {
|
function initMap() {
|
||||||
return new google.maps.LatLngBounds(
|
$.extend(self, {
|
||||||
new google.maps.LatLng(place.points.southwest[0], place.points.southwest[1]),
|
geocoder: new google.maps.Geocoder(),
|
||||||
new google.maps.LatLng(place.points.northeast[0], place.points.northeast[1])
|
selected: -1
|
||||||
);
|
});
|
||||||
}
|
if (Ox.isObject(self.options.places[0])) {
|
||||||
});
|
$.each(self.options.places, function(i, place) {
|
||||||
loadMap();
|
place.bounds = getBounds(),
|
||||||
} else {
|
place.center = place.bounds.getCenter();
|
||||||
self.counter = 0;
|
$.extend(place, {
|
||||||
$.each(self.options.places, function(i, place) {
|
marker: new Marker(place),
|
||||||
getLocationByName(place, function(place) {
|
polygon: new Polygon(place)
|
||||||
Ox.print(self.counter, i, place);
|
});
|
||||||
self.options.places[i] = place;
|
self.bounds = i == 0 ? getBounds() : self.bounds.union(place.bounds);
|
||||||
if (self.counter++ == self.options.places.length - 1) {
|
self.options.places[i] = place;
|
||||||
loadMap();
|
function getBounds() {
|
||||||
}
|
return new google.maps.LatLngBounds(
|
||||||
});
|
new google.maps.LatLng(place.points.southwest[0], place.points.southwest[1]),
|
||||||
});
|
new google.maps.LatLng(place.points.northeast[0], place.points.northeast[1])
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
loadMap();
|
||||||
|
} else {
|
||||||
|
self.counter = 0;
|
||||||
|
$.each(self.options.places, function(i, place) {
|
||||||
|
getLocationByName(place, function(place) {
|
||||||
|
Ox.print(self.counter, i, place);
|
||||||
|
self.options.places[i] = place;
|
||||||
|
if (self.counter++ == self.options.places.length - 1) {
|
||||||
|
loadMap();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function loadMap() {
|
function loadMap() {
|
||||||
self.center = self.bounds ? self.bounds.getCenter() : new google.maps.LatLng(0, 0);
|
self.center = self.bounds ? self.bounds.getCenter() : new google.maps.LatLng(0, 0);
|
||||||
|
@ -7328,9 +7341,9 @@ requires
|
||||||
});
|
});
|
||||||
resize();
|
resize();
|
||||||
that.gainFocus();
|
that.gainFocus();
|
||||||
|
that.triggerEvent('loaded');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function canContain(outerBounds, innerBounds) {
|
function canContain(outerBounds, innerBounds) {
|
||||||
var outerSpan = outerBounds.toSpan(),
|
var outerSpan = outerBounds.toSpan(),
|
||||||
innerSpan = innerBounds.toSpan();
|
innerSpan = innerBounds.toSpan();
|
||||||
|
|
Loading…
Reference in a new issue