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

Commit

Permalink
Improved init speed
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan Verheul committed Feb 17, 2012
1 parent 02b01dc commit bc61df5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
4 changes: 4 additions & 0 deletions demo/index2.html
Expand Up @@ -14,6 +14,10 @@ <h1>BootMap demo</h1>

<p class="info">This is the demo.</p>

<div id="map" style="width: 400px; height:400px" data-map data-format="json">
{ &quot;type&quot;: &quot;Polygon&quot;, &quot;coordinates&quot;: [ [ [ 4.658203125, 52.308478623662999 ], [ 4.98779296875, 52.502847659403997 ], [ 4.9658203125, 52.200873717332001 ], [ 4.658203125, 52.308478623662999 ] ] ] }
</div>

<div id="map1" data-map data-format="json" style="width: 400px; height: 300px"></div>

<textarea id="map2_data" data-map="map1" data-format="wkt" data-stroke-color="#f00" data-fill-color="#0f0">
Expand Down
19 changes: 11 additions & 8 deletions src/bootmap.js
Expand Up @@ -610,7 +610,7 @@
});
if (html) {
opts.text = html;
opts.map = $elem.attr('id');
opts.map = $elem;
bootmap.initLayer(elem, opts);
}
};
Expand All @@ -624,7 +624,11 @@
return;
}
if (layer.map) {
$mapElem = $("#" + layer.map);
if (typeof(layer.map) === 'object') {
$mapElem = layer.map;
} else {
$mapElem = $("#" + layer.map);
}
map = $mapElem.data('map');
mapData = $mapElem.data('mapData');
}
Expand Down Expand Up @@ -662,17 +666,16 @@
options = $.extend({}, $.fn.options, options);
this.each(function () {
var map = $(this).attr('data-map');
var layers = [];
if (!map || map === $(this).attr('id')) {
bootmap.initMap(this, options);
} else {
layers.push(this);
}
});
return this.each(function () {
var map = $(this).attr('data-map');
if (map && map !== $(this).attr('id')) {
bootmap.initLayer(this, options);
}
$.each(layers, function(index, layer) {
bootmap.initLayer(layer, options);
});
return this;
};

$.fn.bootmap.defaults = {
Expand Down

0 comments on commit bc61df5

Please sign in to comment.