function analysis () { let result = {} let args = location.search.substr(1) args = args.split('&') args.forEach(arg => { let index = arg.indexOf('=') if (~index) { result[arg.substring(0, index)] = Number(arg.substr(index + 1)) } }) if (!result.lat || !result.lon) { result.lat = 22.252832648721693 result.lon = 113.57727389730132 } result.zoom = result.zoom || 16 result.pitch = result.pitch || 60 result.bearing = result.bearing || 60 return result } let listStatus = (() => { let args = analysis() return function () { let result = [] let center = map.getCenter() args.lon = center.x args.lat = center.y args.zoom = map.getZoom() args.pitch = map.getPitch() args.bearing = map.getBearing() for (let key in args) { result.push(`${key}=${args[key]}`) } let url = location.pathname + '?' + result.join('&') history.pushState({ url, title: document.title }, document.title, url) } })() function mapGoto(args, duration = 1000) { // map.animateTo({ // center: [(map.getCenter().x + args.center[0]) / 2, // (map.getCenter().y + args.center[1]) / 2], // zoom: 15 // }, {duration: 2000}); // setTimeout(() => { map.animateTo(args, {duration}); // }, 2000) } export { mapGoto, analysis, listStatus }