You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
586 B
18 lines
586 B
var ipLocation = require('./ip-location')
|
|
|
|
register_hook('init_callback', function (callback) {
|
|
if ('checkIpLocation' in config && !config.checkIpLocation) {
|
|
map.setView(config.defaultView, 'zoom' in config.defaultView ? config.defaultView.zoom : 14)
|
|
return callback()
|
|
}
|
|
|
|
ipLocation('', function (err, ipLoc) {
|
|
if (typeof ipLoc === 'object' && 'latitude' in ipLoc) {
|
|
map.setView([ ipLoc.latitude, ipLoc.longitude ], 14)
|
|
} else {
|
|
map.setView(config.defaultView, 'zoom' in config.defaultView ? config.defaultView.zoom : 14)
|
|
}
|
|
|
|
callback()
|
|
})
|
|
})
|