Skip to content
This repository has been archived by the owner on Jul 6, 2018. It is now read-only.

Commit

Permalink
Updated gh-pages from Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan Verheul committed Mar 1, 2012
1 parent b8de947 commit b0e377f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 28 deletions.
9 changes: 4 additions & 5 deletions docs/temp.html

Large diffs are not rendered by default.

50 changes: 28 additions & 22 deletions src/bootmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,7 @@
};

bootmap.initLayer = function(elem, options) {
var map, mapData, $mapElem;
var layer, overlay, overlays, i;
var bounds, center, ne;
var map, layer, mapData, $mapElem;
var opts = $.extend({}, options);
layer = parseLayerElem(elem, opts);
if (!layer) {
Expand All @@ -620,24 +618,6 @@
throw new Error("Cannot find map: " + layer.map ? layer.map : "(none)");
}
mapData.layers.push(layer);
bounds = map.getBounds();
if (!bounds) {
bounds = new google.maps.LatLngBounds();
}
overlays = createOverlaysFromLayers(mapData.layers);
for (i = 0; i < overlays.length; i++) {
overlay = overlays[i];
overlay.setMap(map);
bounds.union(getBoundsFromOverlay(overlay));
}
center = bounds.getCenter();
if (center.equals(bounds.getNorthEast())) {
bounds = new google.maps.Circle({
center: center,
radius: 1000
}).getBounds();
}
map.fitBounds(bounds);
$mapElem.data({
map: map,
mapData: mapData
Expand All @@ -653,19 +633,45 @@
};

$.fn.bootmap = function (options) {
var layers = [];
var layers = [], maps = [];
options = $.extend({}, $.fn.options, options);
this.each(function () {
var map = $(this).attr('data-map');
if (!map || map === $(this).attr('id')) {
bootmap.initMap(this, options);
maps.push(this);
} else {
layers.push(this);
}
});
$.each(layers, function(index, layer) {
bootmap.initLayer(layer, options);
});
$.each(maps, function(index, mapElem) {
var layer, overlay, overlays, i;
var bounds, center, ne;
var $mapElem = $(mapElem);
var map = $mapElem.data('map');
var mapData = $mapElem.data('mapData');
var bounds = map.getBounds();
if (!bounds) {
bounds = new google.maps.LatLngBounds();
}
overlays = createOverlaysFromLayers(mapData.layers);
for (i = 0; i < overlays.length; i++) {
overlay = overlays[i];
overlay.setMap(map);
bounds.union(getBoundsFromOverlay(overlay));
}
center = bounds.getCenter();
if (center.equals(bounds.getNorthEast())) {
bounds = new google.maps.Circle({
center: center,
radius: 1000
}).getBounds();
}
map.fitBounds(bounds);
});
return this;
};

Expand Down
Loading

0 comments on commit b0e377f

Please sign in to comment.