1
0
forked from x/volcanos

opt location.js

This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-09-22 07:16:46 +08:00
parent c81f803764
commit 5355a465fd
7 changed files with 186 additions and 244 deletions

View File

@ -261,6 +261,7 @@ var icon = {
SEARCH: "bi bi-search", TERMINAL: "bi bi-terminal",
}
var http = {
GET: "GET", PUT: "PUT", POST: "POST", DELETE: "DELETE",
ContentType: "Content-Type",
}
var mime = {

View File

@ -18,20 +18,19 @@ Volcanos(chat.ONENGINE, {_init: function(can, meta, list, cb, target) {
if (!sub || !mod || !fun) { can.misc.Warn(ice.ErrNotFound, cmds); return can.base.isFunc(cb) && cb(msg.Echo(ice.ErrWarn, ice.ErrNotFound, cmds)) }
return can.core.CallFunc(fun, {event: event, can: sub, msg: msg, cmds: cmds.slice(2), cb: cb, target: sub._target, button: key, cmd: key, arg: cmds.slice(2), list: cmds.slice(2)}, mod)
},
_remote: function(event, can, msg, panel, cmds, cb) {
_remote: function(event, can, msg, panel, cmds, cb) { var sub = msg._can;
if (panel.onengine._plugin(event, can, msg, panel, cmds, cb)) { return }
if (panel.onengine._engine(event, can, msg, panel, cmds, cb)) { return }
if (panel.onengine._static(event, can, msg, panel, cmds, cb)) { return }
var toast, _toast = msg.Option(chat._TOAST); if (_toast) { can.onmotion.delay(can, function() { if (msg._can && msg._can._toast) { return } toast = toast||can.user.toastProcess(msg._can, _toast) }, 500) }
var sub = msg._can;
if (can.base.isUndefined(msg[ice.MSG_DAEMON])) { can.base.isUndefined(sub._daemon) && can.ondaemon._list[0] && (sub._daemon = can.ondaemon._list.push(sub)-1)
if (sub._daemon) { msg.Option(ice.MSG_DAEMON, can.core.Keys(can.ondaemon._list[0], sub._daemon)) }
} if (!can.misc.CookieSessid(can) && can.user.info.sessid) { msg.Option(ice.MSG_SESSID, can.user.info.sessid) }
msg.OptionDefault(ice.MSG_LANGUAGE, can.user.info.language), msg.OptionDefault(ice.MSG_THEME, can.getHeader(chat.THEME))
can.base.isIn(sub.ConfIndex(), "qrcode", "cli.qrcode") && can.page.exportValue(sub, msg)
can.onengine.signal(panel, chat.ONREMOTE, can.request({}, {_follow: panel._follow, _msg: msg, _cmds: cmds}))
} can.base.isIn(sub.ConfIndex(), "qrcode", "cli.qrcode") && can.page.exportValue(sub, msg)
if (!can.misc.CookieSessid(can) && can.user.info.sessid) { msg.Option(ice.MSG_SESSID, can.user.info.sessid) }
var names = msg.Option(chat._NAMES)||panel._names||((can.Conf("iceberg")||Volcanos.meta.iceberg)+"/chat/"+panel._name+"/")
can.misc.Run(event, can, {names: names, daemon: msg[ice.MSG_DAEMON]}, cmds, function(msg) { toast && toast.close(), toast = true
names = can.base.MergeURL(names, ice.MSG_INDEX, sub.ConfIndex(), ice.MSG_LANGUAGE, can.user.info.language, ice.MSG_THEME, can.getHeader(chat.THEME))
can.onengine.signal(panel, chat.ONREMOTE, can.request({}, {_follow: panel._follow, _msg: msg, _cmds: cmds, names: names}))
can.misc.Run(event, can, {names: names}, cmds, function(msg) { toast && toast.close && toast.close(), toast = true
can.base.isFunc(cb) && cb(msg), Volcanos.meta.pack[can.core.Keys(panel._name, cmds.join(mdb.FS))] = msg
})
},

View File

@ -254,6 +254,11 @@ div.project div.zone>div.item>div.icon { margin-left:3px; float:right; }
div.project div.zone>div.list>div.zone>div.item { text-align:left; padding-left:20px; }
div.project div.zone>div.list>div.zone>div.item:hover { margin-left:10px; transition:all 0.3s; }
div.project div.list fieldset { position:static; }
div.project div.action { width:100%; }
div.project div.action div.item.search { width:100%; position:relative; }
div.project div.action div.item.search>i:first-child { position:absolute; padding:5px; }
div.project div.action div.item.search>input { width:100% !important; padding-left:25px; }
div.project div.action div.item.search>span { right:10px; }
div.content { position:relative; }
div.content>div.toggle { position:absolute; }
div.content>div.toggle:hover { background-color:var(--hover-bg-color); color:var(--hover-fg-color); cursor:pointer; }
@ -463,7 +468,6 @@ fieldset.xterm>div.layout { clear:both; }
fieldset.xterm div.layout div.output { border-left:var(--box-border); border-top:var(--box-border); }
fieldset.xterm div.layout div.output.select { border:var(--box-border)}
fieldset.xterm>div.action>div.tabs:only-child { display:none; }
fieldset.location>div.action input[type=text] { width:40px; }
fieldset.config form.option input[name=key] { width:240px; }
fieldset.qrcode>div.output div.code { padding:0; }
fieldset.macos.desktop.cmd>div.output>fieldset.macos.dock { z-index:11; }
@ -484,6 +488,9 @@ fieldset.draw.trend div.output { overflow:hidden; }
fieldset.draw.spide div.output { overflow-y:hidden; }
fieldset.draw.spide div.output svg text { cursor:pointer; }
fieldset.draw.spide div.output svg path { stroke-width:1; }
fieldset.web.chat.location>div.action input[type=text] { width:80px !important; }
fieldset.web.chat.location>div.output>div.layout>div.layout>div.profile { position:absolute; top:0; right:0; height:200px; width:200px; z-index:5; border-left:none; }
fieldset.web.chat.location>div.output>div.layout>div.layout { position:relative; }
body.web.wiki.portal { background-color:rgb(22 31 49); }
fieldset.web.code.docker.studio>div.action>div.item { font-style:italic; height:32px; padding:5px 10px; }
fieldset.web.code.docker.studio>div.output>fieldset { margin:0; }

View File

@ -83,7 +83,7 @@ Volcanos("misc", {
Event: function(event, can, cb) { for (var i = 3; i < arguments.length; i++) { can.request(event, arguments[i]) } cb(can.request(event)) },
Run: function(event, can, dataset, cmds, cb) { var msg = can.request(event), _can = msg._can; _can._fields && _can.sup && (_can = _can.sup)
var form = {cmds: cmds}; can.core.List(msg.option, function(key) { !can.base.isIn(key, "log.caller", "_handle", "_toast") && msg[key] && (form[key] = msg[key]) })
can.misc.POST(can, msg, can.base.MergeURL(dataset.names.toLowerCase(), ice.MSG_INDEX, _can._index), form, cb)
can.misc.POST(can, msg, dataset.names.toLowerCase(), form, cb)
},
POST: function(can, msg, url, form, cb, cbs) { var xhr = new XMLHttpRequest(), begin = new Date(); msg._xhr = xhr
var data = can.core.ItemForm(form, function(v, i, k) { return k+mdb.EQ+encodeURIComponent(v) }).join("&")

View File

@ -4,8 +4,8 @@ Volcanos("user", {
scanQRCode: function(can, cb) { can.user.input(event, can, [{type: html.TEXTAREA, name: mdb.TEXT, text: ""}], function(list) { cb(can.base.ParseJSON(list[0])) }) },
getLocation: function(can, cb) { var call = arguments.callee; if (call._res) { return cb(call._res) }
navigator.geolocation.getCurrentPosition(function(res) {
cb(call._res = {latitude: parseInt(res.coords.latitude*100000), longitude: parseInt(res.coords.longitude*100000)})
}, function(some) { can.base.isFunc(cb) && cb({type: "location", name: "北京市", text: "天安门", latitude: 3998412, longitude: 11630748}) } )
cb(call._res = {type: "ip", name: "当前位置", text: "某某大街", latitude: res.coords.latitude, longitude: res.coords.longitude})
}, function(some) { can.base.isFunc(cb) && cb({type: "location", name: "北京市", text: "天安门", latitude: 39.98412, longitude: 116.30748}) } )
},
openLocation: function(can, msg) {
window.open("https://map.baidu.com/search/"+encodeURIComponent(msg.Option(mdb.TEXT))

View File

@ -1,226 +1,108 @@
Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) {
can.onmotion.clear(can), can.ui = can.onappend.layout(can), can.base.isFunc(cb) && cb(msg)
!can.isCmdMode() && can.ConfHeight(window.innerHeight - 5*html.ACTION_HEIGHT - 5*html.PLUGIN_MARGIN)
can.user.isMobile && can.ConfHeight(window.innerHeight-html.ACTION_HEIGHT)
can.user.isMobile && can.onmotion.hidden(can, can.ui.project)
can.user.isMobile && can.onmotion.hidden(can, can._action)
can.user.isMobile && can.onmotion.hidden(can, can._option)
can.user.isMobile && can.onmotion.hidden(can, can._status)
can.page.styleWidth(can, can.ui.project, 240), can.onmotion.toggle(can, can.ui.profile, true)
can.page.ClassList.add(can, can.ui.project, ice.AUTO)
can.page.ClassList.add(can, can.ui.profile, ice.AUTO)
can.onappend._status(can, can.onexport.list)
can.require([can.base.MergeURL("https://map.qq.com/api/gljs", "v", "1.exp", "libraries", "service", "key", can.Conf(aaa.TOKEN))], function() {
var res = {type: "unknown", latitude: 3998412, longitude: 11630748}, current = can.base.Obj(msg.Option(chat.LOCATION))
if (current.status === 0) { res = can.onexport.point(can, current.result.location, current.result.ad_info), res.type = "ip", res.name = current.result.ip, can.Status(res) }
can._current = res, can.onimport._layout(can), can.user.agent.getLocation(can, function(res) { res.type = "current", can.onimport.center(can, can._current = res) })
Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) { can.ui = can.onappend.layout(can), can.ui.layout(can.ConfHeight(), can.ConfWidth()), cb && cb(msg)
can.require([msg.Option(nfs.SCRIPT)], function() {
var res = {type: "unknown", latitude: 39.984120, longitude: 116.307480}, current = can.base.Obj(msg.Option(chat.LOCATION))
res.nation = current.nation||current.country, res.province = current.province||current.regionName, res.city = current.city
res.latitude = current.latitude||current.lat||res.latitude, res.longitude = current.longitude||current.lon||res.longitude
res.name = current.name||"当前位置", res.text = current.text||"某某大街", res.ip = current.ip||current.query
can.Status(can._current = res), can.onimport._content(can, can._current), can.onimport._project(can), msg.Table(function(item) { can.onimport._item(can, item) })
can.user.agent.getLocation(can, function(res) { res.type = "current", can.onaction.center(can, can._current = res) })
})
},
_layout: function(can) { can.onmotion.clear(can, can.ui.content), can.onmotion.clear(can, can.ui.project)
can.page.style(can, can.ui.content, html.HEIGHT, can.ConfHeight(), html.WIDTH, can.ConfWidth())
can.page.style(can, can.ui.project, html.MAX_HEIGHT, can.ConfHeight())
can.onimport.zone(can, [
{name: "direction"},
{name: "favor", _menu: shy({"play": function(event, can, button) {
can.core.Next(can.page.Select(can, can.ui.favor._target, html.DIV_ITEM), function(item, next) {
item.click(), can.onmotion.delay(can, next, 2000)
}, function() { can.user.toastSuccess(can) })
}})},
{name: "explore", _init: function(target, zone) {
zone._search.onkeyup = function(event) { can.misc.Event(event, can, function(msg) {
event.key == "Enter" && can.onimport._search0(can, event.target.value)
}) }
}},
{name: "search", _init: function(target, zone) {
zone._search.onkeyup = function(event) { can.misc.Event(event, can, function(msg) {
event.key == "Enter" && can.onimport._search(can, event.target.value)
}) }
}},
{name: "district", _init: function(target, zone) {
can.onimport._province(can, target)
}},
], can.ui.project), can.onimport._show(can, can._current), can.onimport._mark(can)
can.mark && can.mark.add({position: can.onimport.point(can, can._current), properties: can._current})
can._msg.Table(function(item) { can.onimport._item(can, item) })
},
_search0: function(can, keyword) { var p = can.onimport.point(can, can.current.item)
can.runAction(can.request({}, {"boundary": "nearby("+can.base.join([p.lat, p.lng, "500"], mdb.FS)+")", "page_index": 1, "keyword": keyword}), "search", [], function(msg) {
_project: function(can) { can.onmotion.clear(can, can.ui.project), can.onimport.zone(can, [
{name: "explore"}, {name: "search"}, {name: "direction"},
{name: "favor", _menu: shy({"play": function(event, can, button) {
can.core.Next(can.page.Select(can, can.ui.zone.favor._target, html.DIV_ITEM), function(item, next) {
item.click(), can.onmotion.delay(can, next, 2000)
}, function() { can.user.toastSuccess(can) })
}})},
{name: "district", _init: function(target, zone) { can.onimport._province(can, target) }},
], can.ui.project) },
_explore: function(can, keyword, i) { var p = can.onimport.point(can, can.current.item)
can.runAction(can.request({}, {_method: http.GET, "boundary": "nearby("+can.base.join([p.lat, p.lng, "500"], mdb.FS)+")", "page_index": i||1, "keyword": keyword}), "search", [], function(msg) {
var res = can.base.Obj(msg.Result()); can.core.List(res.data, function(item) {
can.onimport._item(can, can.onexport.point(can, item.location, {type: item.category, name: item.title, text: item.address}), can.ui.explore._target)
can.onimport._item(can, can.onexport.point(can, item.location, {type: item.category, name: item.title, text: item.address}), can.ui.zone.explore._target)
})
})
},
_search: function(can, keyword) { var p = can.onimport.point(can, can.current.item)
can.runAction(can.request({}, {"boundary": "region("+can.base.join([can.Status("city"), p.lat, p.lng], mdb.FS)+")", "page_index": 1, "keyword": keyword}), "search", [], function(msg) {
_search: function(can, keyword, i) { var p = can.onimport.point(can, can.current.item)
can.runAction(can.request({}, {_method: http.GET, "boundary": "region("+can.base.join([can.Status("city"), p.lat, p.lng], mdb.FS)+")", "page_index": i||1, "keyword": keyword}), "search", [], function(msg) {
var res = can.base.Obj(msg.Result()); can.core.List(res.data, function(item) {
can.onimport._item(can, can.onexport.point(can, item.location, {type: item.category, name: item.title, text: item.address}), can.ui.search._target)
can.onimport._item(can, can.onexport.point(can, item.location, {type: item.category, name: item.title, text: item.address}), can.ui.zone.search._target)
})
})
},
_list_result: function(can, msg, cb) { var res = can.base.Obj(msg.Result())
return can.core.List(res.result[0], function(item) { item.name = item.name||item.fullname; return can.base.isFunc(cb)? cb(item): item })
_list_result: function(can, msg, cb) { var res = can.base.Obj(msg.Result()); if (res.status) { can.user.toastFailure(can, res.message); return }
return res && can.core.List(res.result[0], function(item) { item.name = item.name||item.fullname; return can.base.isFunc(cb)? cb(item): item })
},
_district: function(can, id, cb) {
can.runAction(can.request({}, {id: id}), "district", [], cb)
},
_province: function(can, target) {
can.onimport._district(can, "", function(msg) {
can.onimport._list_result(can, msg, function(province) {
can.onimport.item(can, province, function(event, _, show) { if (show === false) { return }
can.onimport.center(can, can.onexport.point(can, province.location, {type: "province", name: province.name, text: province.fullname}))
can.map.setZoom(can.Action("zoom", 8)), can.Status({nation: "中国", province: province.fullname})
show === true || can.onimport._city(can, province, event.target)
}, function() {}, target)
})
})
},
_city: function(can, province, target) {
can.onimport._district(can, province.id, function(msg) {
can.onimport.itemlist(can, can.onimport._list_result(can, msg), function(event, city, show) { if (show === false) { return }
can.onimport.center(can, can.onexport.point(can, city.location, {type: "city", name: city.name, text: city.fullname}))
can.map.setZoom(can.Action("zoom", 12)), can.Status({nation: "中国", province: province.fullname, city: city.fullname})
show === true || can.onimport._county(can, province, city, event.target)
_district: function(can, id, cb) { can.runAction(can.request({}, {_method: http.GET, id: id}), "district", [], cb) },
_province: function(can, target) { can.onimport._district(can, "", function(msg) {
can.onimport._list_result(can, msg, function(province) {
can.onimport.item(can, province, function(event, _, show) { if (show === false) { return }
can.onaction.center(can, can.onexport.point(can, province.location, {type: "province", name: province.name, text: province.fullname}))
can.map.setZoom(can.Action("zoom", 8)), can.Status({nation: "中国", province: province.fullname})
show === true || can.onimport._city(can, province, event.target)
}, function() {}, target)
})
},
_county: function(can, province, city, target) {
can.onimport._district(can, city.id, function(msg) {
can.onimport.itemlist(can, can.onimport._list_result(can, msg), function(event, county) {
can.onimport.center(can, can.onexport.point(can, county.location, {type: "county", name: city.name, text: county.fullname}))
can.map.setZoom(can.Action("zoom", 15)), can.Status({nation: "中国", province: province.fullname, city: city.fullname})
}, function() {}, target)
})
},
_show: function(can, item) {
can.map = new TMap.Map(can.ui.content, {center: can.onimport.point(can, item), zoom: can.Action("zoom"), pitch: can.Action("pitch"), rotation: can.Action("rotation"), mapStyleId: "style2"})
can.page.Select(can, can._target, "div.content>div", function(item) { can.page.style(can, item, {"z-index": 3}) })
can.current = {
label: new TMap.MultiLabel({map: can.map, geometries: [{id: "current", position: can.onimport.point(can, item), content: item.name}]}),
marker: new TMap.MultiMarker({map: can.map, geometries: [{id: "current", position: can.onimport.point(can, item)}]}),
info: can.onimport.info(can, item), hover: can.onimport.info(can, item),
circle: can.onimport.circle(can, item, 100), item: item,
}
can.map.on("rotate", function(event) { can.Action("rotation", can.map.getRotation()) })
can.map.on("pitch", function(event) { can.Action("pitch", can.map.getPitch()) })
}) },
_city: function(can, province, target) { can.onimport._district(can, province.id, function(msg) {
can.onimport.itemlist(can, can.onimport._list_result(can, msg), function(event, city, show) { if (show === false) { return }
can.onaction.center(can, can.onexport.point(can, city.location, {type: "city", name: city.name, text: city.fullname}))
can.map.setZoom(can.Action("zoom", 12)), can.Status({nation: "中国", province: province.fullname, city: city.fullname})
show === true || can.onimport._county(can, province, city, event.target)
}, function() {}, target)
}) },
_county: function(can, province, city, target) { can.onimport._district(can, city.id, function(msg) {
can.onimport.itemlist(can, can.onimport._list_result(can, msg), function(event, county) {
can.onaction.center(can, can.onexport.point(can, county.location, {type: "county", name: city.name, text: county.fullname}))
can.map.setZoom(can.Action("zoom", 15)), can.Status({nation: "中国", province: province.fullname, city: city.fullname})
}, function() {}, target)
}) },
_content: function(can, item) {
can.map = new TMap.Map(can.ui.content, {center: can.onimport.point(can, item), zoom: can.Action("zoom"), pitch: can.Action("pitch"), rotation: can.Action("rotation"),
mapStyleId: 'style3'})
can.map.on("zoom", function(event) { can.Action("zoom", can.map.getZoom()) })
can.map.on("click", function(event) {
var point = can.onaction._point(event, can, {name: event.poi? event.poi.name: ""}); can.onimport.center(can, point)
can.Action("mode") == "insert" && can.runAction(can.request({target: {getBoundingClientRect: function() { return point }}}, point), mdb.CREATE, function(msg) {
can.map.on("pitch", function(event) { can.Action("pitch", can.map.getPitch()) })
can.map.on("rotate", function(event) { can.Action("rotation", can.map.getRotation()) })
can.map.on("click", function(event) { var point = can.onaction._point(event, can, {name: event.poi? event.poi.name: ""}); can.onaction.center(can, point)
can.Action("mode") == mdb.INSERT && can.runAction(can.request({target: {getBoundingClientRect: function() { return point }}}, point), mdb.CREATE, function(msg) {
can.onimport._item(can, point)
})
})
can.current = {item: item, info: can.onfigure.info(can, item), hover: can.onfigure.info(can, item),
label: new TMap.MultiLabel({map: can.map, geometries: [{id: "current", position: can.onimport.point(can, item), content: item.name}]}),
marker: new TMap.MultiMarker({map: can.map, geometries: [{id: "current", position: can.onimport.point(can, item)}]}),
circle: can.onfigure.circle(can, item, 100),
}
can.onfigure._mark(can), can.mark && can.mark.add({position: can.onimport.point(can, can._current), properties: can._current})
can.page.Select(can, can._target, "div.content>div", function(item) { can.page.style(can, item, {"z-index": 3}) })
},
_item: function(can, item, target) { if (!item.latitude || !item.longitude) { return }
can.onimport.item(can, item, function(event) {
can.onimport.center(can, item), can.onimport.plugin(can, item)
}, function(event) {
can.onimport.item(can, item, function(event) { can.onaction.center(can, item) }, function(event) {
can.onexport.hover(can, item), can.user.carteRight(event, can, {
direction: function(event, button) { can.onimport.center(can, item), can.onaction[button](event, can, button) },
direction: function(event, button) { can.onaction.center(can, item), can.onaction[button](event, can, button) },
favor: function(event) { can.request(event, item), can.onaction.create(event, can) },
plugin: function(event, button) { can.request(event, item, item.extra)
can.user.input(event, can, [ctx.INDEX, ctx.ARGS], function(args, data) {
can.base.Copy(item.extra, data), can.runAction(event, mdb.MODIFY, args)
plugin: function(event, button) {
can.user.input(can.request(event, item), can, [ctx.INDEX, ctx.ARGS], function(data) {
item.extra = can.base.Copy(item.extra||{}, data), can.onimport.plugin(can, item)
can.runAction(event, mdb.MODIFY, ["extra.index", data.index, "extra.args", data.args], function() {})
})
},
})
}, target||can.ui.favor._target)
}, target||can.ui.zone.favor._target)
can.mark && can.mark.add({position: can.onimport.point(can, item), properties: item})
can.cluster && can.cluster.add({position: can.onimport.point(can, item)})
},
_cluster: function(can, msg) {
can.cluster = new TMap.MarkerCluster({map: can.map, geometries: []})
},
_mark: function(can, msg) {
can.mark = new TMap.MultiMarker({map: can.map})
can.mark.on("click", function(event) { if (!event.geometry) { return } var item = event.geometry.properties
can.onimport.center(can, item)
})
can.mark.on("hover", function(event) { if (!event.geometry) { return } var item = event.geometry.properties
can.onexport.hover(can, item)
})
},
_polyline: function(can, path) {
return new TMap.MultiPolyline({
map: can.map,
styles: {
'style_blue': new TMap.PolylineStyle({
'color': '#3777FF', //线填充色
'width': 6, //折线宽度
'borderWidth': 5, //边线宽度
'borderColor': '#FFF', //边线颜色
'lineCap': 'butt' //线端头方式
}),
'style_red': new TMap.PolylineStyle({
'color': '#CC0000', //线填充色
'width': 6, //折线宽度
'borderWidth': 5, //边线宽度
'borderColor': '#CCC', //边线颜色
'lineCap': 'round' //线端头方式
})
},
geometries: [{'styleId': 'style_blue', 'paths': path}]
})
},
_move: function(can) {
can.mark.add({id: 'car', styleId: 'car-down', position: new TMap.LatLng(39.98481500648338, 116.30571126937866)})
can.mark.moveAlong({"car": {path: [
new TMap.LatLng(39.98481500648338, 116.30571126937866),
new TMap.LatLng(39.982266575222155, 116.30596876144409),
new TMap.LatLng(39.982348784165886, 116.3111400604248),
new TMap.LatLng(39.978813710266024, 116.3111400604248),
new TMap.LatLng(39.978813710266024, 116.31699800491333)
], speed: 70}}, {autoRotation:true})
},
point: function(can, item) {
return new TMap.LatLng(item.latitude/100000.0, item.longitude/100000.0)
},
center: function(can, item) { var point = can.onimport.point(can, item)
can.map.setCenter(point), can.Status("name", ""), can.Status("text", ""), can.Status(item), can.Status({latitude: point.lat, longitude: point.lng})
can.current.info.setPosition(point), can.current.info.setContent((item.name||"")+"<br/>"+(item.text||""))
can.current.label.updateGeometries([{id: "current", position: point, content: item.name}])
can.current.marker.updateGeometries([{id: "current", position: point}])
can.current.circle.setGeometries([{center: point, radius: 300}])
can.current.item = item
item._plugin && can.onmotion.toggle(can, item._plugin._target)
},
info: function(can, item) {
return new TMap.InfoWindow({map: can.map,
position: can.onimport.point(can, item), offset: {x: 0, y: -32},
content: (item.name||"")+"<br/>"+(item.text||""),
})
},
circle: function(can, item, radius) {
return new TMap.MultiCircle({
map: can.map, styles: {
circle: new TMap.CircleStyle({
color: 'rgba(41,91,255,0.16)',
showBorder: true,
borderColor: 'rgba(41,91,255,1)',
borderWidth: 2,
}),
},
geometries: [{styleId: 'circle', center: can.onimport.point(can, item), radius: radius||300}],
})
},
point: function(can, item) { return new TMap.LatLng(item.latitude, item.longitude) },
plugin: function(can, item) {
if (can.onmotion.cache(can, function() { return item.hash }, can.ui.profile)) {
} else { item.extra = can.base.Obj(item.extra, {})
item.extra.index && can.onimport.plug(can, {index: item.extra.index, args: item.extra.args}, function(sub) { item._plugin = sub
can.page.style(can, sub._target, html.MAX_HEIGHT, sub.ConfHeight(can.ConfHeight()), html.MAX_WIDTH, sub.ConfWidth(can.ConfWidth()*3/4))
can.page.style(can, sub._output, html.MAX_HEIGHT, sub.ConfHeight(can.ConfHeight()-2*html.ACTION_HEIGHT), html.MAX_WIDTH, sub.ConfWidth(can.ConfWidth()*3/4))
}, can.ui.profile)
}
var extra = can.base.Obj(item.extra, {}); if (!extra.index) { return can.onmotion.toggle(can, can.ui.profile, false) }
can.onmotion.toggle(can, can.ui.profile, true)
if (can.onmotion.cache(can, function() { return item.hash }, can.ui.profile)) { return true}
can.onappend.plugin(can, {index: extra.index, args: extra.args}, function(sub) { item._plugin = sub
sub.onaction._close = function() { can.onmotion.hidden(can, can.ui.profile) }
sub.onexport.output = function() { sub.onimport.size(sub, can.ConfHeight()/2, can.ConfWidth()/2, true)
can.page.style(can, can.ui.profile, html.HEIGHT, can.ConfHeight()/2, html.WIDTH, can.ConfWidth()/2)
}
}, can.ui.profile)
return true
},
_plugin: function(can, item, meta) {
function myInfoWindow(options) { TMap.DOMOverlay.call(this, options) }
@ -234,8 +116,6 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) {
sub.onaction.close = function(event) { can.misc.Event(event, can, function(msg) {
can.onmotion.hidden(can, sub._target)
}) }
// can.page.style(can, sub._output, html.MAX_HEIGHT, sub.ConfHeight(can.ConfHeight()/2))
// can.page.style(can, sub._output, html.MAX_WIDTH, sub.ConfWidth(can.ConfWidth()/2))
item._plugin = sub
}, can._output, ui.fieldset)
return ui.fieldset
@ -248,40 +128,99 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb, target) {
return new myInfoWindow({map: can.map, position: can.onimport.point(can, item), meta: meta})
},
})
Volcanos(chat.ONACTION, {list: [["mode", "select", "insert"],
{type: html.TEXT, name: "zoom", value: 17, range: [3, 21]},
{type: html.TEXT, name: "pitch", value: 30, range: [0, 80, 5]},
{type: html.TEXT, name: "rotation", value: "0", range: [0, 360, 10]},
"current", "explore", "create", "direction"],
_trans: {current: "定位", favor: "收藏"},
Volcanos(chat.ONFIGURE, {
circle: function(can, item, radius) {
return new TMap.MultiCircle({
map: can.map, styles: {circle: new TMap.CircleStyle({color: 'rgba(41,91,255,0.16)', borderColor: 'rgba(41,91,255,1)', borderWidth: 2, showBorder: true})},
geometries: [{styleId: 'circle', center: can.onimport.point(can, item), radius: radius||300}],
})
},
info: function(can, item) {
return new TMap.InfoWindow({map: can.map,
position: can.onimport.point(can, item), offset: {x: 0, y: -32},
content: (item.name||"")+"<br/>"+(item.text||""),
})
},
_mark: function(can, msg) { can.mark = new TMap.MultiMarker({map: can.map})
can.mark.on("click", function(event) { if (!event.geometry) { return } var item = event.geometry.properties; can.onaction.center(can, item) })
can.mark.on("hover", function(event) { if (!event.geometry) { return } var item = event.geometry.properties; can.onexport.hover(can, item) })
},
_polyline: function(can, path) { return new TMap.MultiPolyline({
map: can.map, styles: {
'style_blue': new TMap.PolylineStyle({
'color': '#3777FF', //线填充色
'width': 6, //折线宽度
'borderWidth': 5, //边线宽度
'borderColor': '#FFF', //边线颜色
'lineCap': 'butt' //线端头方式
}),
'style_red': new TMap.PolylineStyle({
'color': '#CC0000', //线填充色
'width': 6, //折线宽度
'borderWidth': 5, //边线宽度
'borderColor': '#CCC', //边线颜色
'lineCap': 'round' //线端头方式
})
}, geometries: [{'styleId': 'style_blue', 'paths': path}]
}) },
_move: function(can) {
can.mark.add({id: 'car', styleId: 'car-down', position: new TMap.LatLng(39.98481500648338, 116.30571126937866)})
can.mark.moveAlong({"car": {path: [
new TMap.LatLng(39.98481500648338, 116.30571126937866),
new TMap.LatLng(39.982266575222155, 116.30596876144409),
new TMap.LatLng(39.982348784165886, 116.3111400604248),
new TMap.LatLng(39.978813710266024, 116.3111400604248),
new TMap.LatLng(39.978813710266024, 116.31699800491333)
], speed: 70}}, {autoRotation:true})
},
})
Volcanos(chat.ONACTION, {list: [["mode", mdb.SELECT, mdb.INSERT],
{type: html.TEXT, name: "zoom", value: 16, range: [3, 21]},
{type: html.TEXT, name: "pitch", value: 30, range: [0, 80, 5]},
{type: html.TEXT, name: "rotation", value: 0, range: [0, 360, 10]},
"current:button", "explore", "search", "direction", mdb.CREATE,
], _trans: {current: "定位", favor: "收藏"},
zoom: function(event, can) { can.map.setZoom(can.Action("zoom")) },
pitch: function(event, can) { can.map.setPitch(can.Action("pitch")) },
rotation: function(event, can) { can.map.setRotation(can.Action("rotation")) },
current: function(event, can) { can.onimport.center(can, can._current), can.map.setZoom(can.Action("zoom", 17)), can.map.setPitch(can.Action("pitch", 30)), can.map.setRotation(can.Action("rotation", 0)) },
explore: function(event, can, button) { var p = can.onimport.point(can, can.current.item); can.onmotion.clear(can, can.ui.explore._target)
for (var i = 1; i < 6; i++) {
can.runAction(can.request({}, {"boundary": "nearby("+can.base.join([p.lat, p.lng, "500"], mdb.FS)+")", "page_index": i}), button, [], function(msg) {
var res = can.base.Obj(msg.Result()); can.core.List(res.data, function(item) {
can.onimport._item(can, can.onexport.point(can, item.location, {type: item.category, name: item.title, text: item.address}), can.ui.explore._target)
})
})
}
_point: function(event, can, item) { var rect = can.ui.content.getBoundingClientRect()
return can.base.Copy({left: rect.left+event.point.x, bottom: rect.top+event.point.y, latitude: event.latLng.lat, longitude: event.latLng.lng}, item, true)
},
direction: function(event, can, button) { var p = can.map.getCenter(); can.onmotion.clear(can, can.ui.direction._target)
center: function(can, item) { var point = can.onimport.point(can, item); can.map.setCenter(point); if (!item.name) { return }
can.current.item = item, can.Status(mdb.NAME, ""), can.Status(mdb.TEXT, ""), can.Status(item), can.Status({latitude: point.lat, longitude: point.lng})
can.current.info.setPosition(point), can.current.info.setContent((item.name||"")+"<br/>"+(item.text||""))
can.current.label.updateGeometries([{id: "current", position: point, content: item.name}])
can.current.marker.updateGeometries([{id: "current", position: point}])
can.current.circle.setGeometries([{center: point, radius: 300}])
can.onimport.plugin(can, item)
},
current: function(event, can) { can.onaction.center(can, can._current), can.map.setZoom(can.Action("zoom", 16)), can.map.setPitch(can.Action("pitch", 30)), can.map.setRotation(can.Action("rotation", 0)) },
explore: function(event, can, button) { can.onmotion.clear(can, can.ui.zone.explore._target)
can.user.input(event, can, ["keyword"], function(list) {
for (var i = 1; i < 6; i++) {
can.onimport._explore(can, list[0], i)
}
})
},
search: function(event, can, button) { can.onmotion.clear(can, can.ui.zone.search._target)
can.user.input(event, can, ["keyword"], function(list) {
for (var i = 1; i < 6; i++) {
can.onimport._search(can, list[0], i)
}
})
},
direction: function(event, can, button) { var p = can.map.getCenter(); can.onmotion.clear(can, can.ui.zone.direction._target)
can.user.input(event, can, [["type", "driving", "walking", "bicycling", "transit"]], function(list) {
var from = can.onimport.point(can, can._current), to = can.onimport.point(can, can.current.item)
var msg = can.request({}, {type: list[0], "from": can.base.join([from.lat, from.lng], mdb.FS), "to": can.base.join([to.lat, to.lng], mdb.FS)})
var msg = can.request({}, {_method: http.GET, type: list[0], "from": can.base.join([from.lat, from.lng], mdb.FS), "to": can.base.join([to.lat, to.lng], mdb.FS)})
can.runAction(msg._event, button, [], function(msg) { var res = can.base.Obj(msg.Result()), route = res.result.routes[0]
var coors = route.polyline, pl = [], kr = 1000000
for (var i = 2; i < coors.length; i++) { coors[i] = Number(coors[i - 2]) + Number(coors[i]) / kr }
for (var i = 0; i < coors.length; i += 2) { pl.push(new TMap.LatLng(coors[i], coors[i+1])) }
can.onimport._polyline(can, pl)
can.core.List(route.steps, function(item) { var i = item.polyline_idx[0]
can.onimport._item(can, can.onexport.point(can, {lat: coors[i], lng: coors[i+1]}, {type: item.category, name: item.instruction, text: item.act_desc}), can.ui.direction._target)
}), can.user.toastProcess(can, "distance: "+route.distance+" duration: "+route.duration)
var coors = route.polyline, pl = [], kr = 1000000
for (var i = 2; i < coors.length; i++) { coors[i] = Number(coors[i - 2]) + Number(coors[i]) / kr }
for (var i = 0; i < coors.length; i += 2) { pl.push(new TMap.LatLng(coors[i], coors[i+1])) }
can.onfigure._polyline(can, pl)
can.core.List(route.steps, function(item) { var i = item.polyline_idx[0]
can.onimport._item(can, can.onexport.point(can, {lat: coors[i], lng: coors[i+1]}, {type: item.category, name: item.instruction, text: item.act_desc}), can.ui.zone.direction._target)
}), can.user.toastProcess(can, "distance: "+route.distance+" duration: "+route.duration)
})
})
},
@ -292,15 +231,12 @@ Volcanos(chat.ONACTION, {list: [["mode", "select", "insert"],
}, true)
})
},
_point: function(event, can, item) { var rect = can.ui.content.getBoundingClientRect()
return can.base.Copy({left: rect.left+event.point.x, bottom: rect.top+event.point.y, latitude: parseInt(event.latLng.lat*100000), longitude: parseInt(event.latLng.lng*100000)}, item, true)
},
})
Volcanos(chat.ONEXPORT, {list: ["nation", "province", "city", "latitude", "longitude", "type", "name", "text"],
point: function(can, point, item) { return can.base.Copy({latitude: parseInt(point.lat*100000), longitude: parseInt(point.lng*100000)}, item, true) },
Volcanos(chat.ONEXPORT, {list: ["nation", "province", "city", "latitude", "longitude", "ip", "type", "name", "text"],
point: function(can, point, item) { return can.base.Copy({latitude: point.lat, longitude: point.lng}, item, true) },
center: function(can) { return can.onexport.point(can, can.map.getCenter()) },
current: function(can) {
var p = can.onexport.center(can); p.latitude /= 100000, p.longitude /= 100000; can.Status(p)
var p = can.onexport.center(can); p.latitude, p.longitude; can.Status(p)
can.current.marker.updateGeometries([{id: "current", position: can.map.getCenter()}])
can.current.label.updateGeometries([{id: "current", position: can.map.getCenter()}])
can.current.circle.setGeometries([{center: can.map.getCenter(), radius: 300}])

View File

@ -51,8 +51,7 @@ var Volcanos = shy({iceberg: "", volcano: "", frame: chat.FRAME_JS,
can.base.isFunc(item.Option)? can.core.List(item.Option(), function(key) { set(key, item.Option(key)) }): can.core.Item(can.base.isFunc(item)? item(): item, set)
}); return msg
},
request: function(event) {
event = event||{}, event = event._event||event
request: function(event) { event = event||{}, event = event._event||event
var msg = event._msg||can.misc.Message(event, can); event._msg = msg
function set(key, value) { if (key == "_method") { return msg._method = value }
value == "" || msg.Option(key) || msg.Option(key, value)