Add leaflet-locate control, invisible currently.

This commit is contained in:
Tom MacWright 2013-06-10 11:20:29 -07:00 committed by John Firebaugh
parent ef37ad8aaa
commit 73bbee5df9
5 changed files with 207 additions and 3 deletions

View file

@ -17,7 +17,7 @@ var layers;
var objectLayer;
var objectLoader;
function createMap(divName, options) {
function createMap(divName, options, moreOptions) {
if (!layers) {
layers = [
{
@ -51,6 +51,8 @@ function createMap(divName, options) {
];
}
moreOptions = moreOptions || {};
options = $.extend({zoomControl: true, panZoomControl: true, layerControl: true}, options);
map = L.map(divName, $.extend({}, options, {panControl: false, zoomsliderControl: false, maxZoom: 18}));
@ -67,6 +69,13 @@ function createMap(divName, options) {
map.layersControl = layersControl;
}
if (moreOptions.locateControl) {
var loc = L.control.locate({
position: 'topright'
});
loc.addTo(map);
}
for (var i = 0; i < layers.length; i++) {
layers[i].layer = new (layers[i].klass)(layers[i]);
layersControl.addBaseLayer(layers[i].layer, layers[i].name);