mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 09:14:06 +08:00
add love.maps
This commit is contained in:
parent
4a58e09fce
commit
a58ece0f72
@ -4,5 +4,5 @@ var version = struct {
|
|||||||
host string
|
host string
|
||||||
self int
|
self int
|
||||||
}{
|
}{
|
||||||
"2019-09-27 10:34:50", "centos", 607,
|
"2019-09-28 15:18:05", "mac", 611,
|
||||||
}
|
}
|
||||||
|
@ -849,9 +849,12 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
// 响应类型
|
// 响应类型
|
||||||
accept_json := strings.HasPrefix(m.Option("accept"), "application/json")
|
accept_json := strings.HasPrefix(m.Option("accept"), "application/json")
|
||||||
w := m.Optionv("response").(http.ResponseWriter)
|
w := m.Optionv("response").(http.ResponseWriter)
|
||||||
if accept_json {
|
if !accept_json {
|
||||||
w.Header().Set("Content-Type", "text/html")
|
w.Header().Set("Content-Type", "text/html")
|
||||||
|
} else {
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
}
|
}
|
||||||
|
w.Header().Set("Access-Control-Allow-Origin", "api.map.baidu.com")
|
||||||
|
|
||||||
web, ok := m.Target().Server.(*WEB)
|
web, ok := m.Target().Server.(*WEB)
|
||||||
m.Assert(ok)
|
m.Assert(ok)
|
||||||
|
@ -1,4 +1,16 @@
|
|||||||
{init: function(run, field, option, output) {return {
|
{init: function(run, field, option, output) {
|
||||||
|
var id
|
||||||
|
return {
|
||||||
|
initMap: function() {var plugin = field.Plugin
|
||||||
|
var width = field.parentNode.clientWidth-40
|
||||||
|
!id && (id = plugin.id+"map"+plugin.ID())
|
||||||
|
kit.AppendChilds(output, [{type: "div", data: {id: id}, style: {width: width+"px", height: width*3/5}}])
|
||||||
|
map = new BMap.Map(id)
|
||||||
|
map.addControl(new BMap.NavigationControl())
|
||||||
|
map.addControl(new BMap.ScaleControl())
|
||||||
|
map.addControl(new BMap.OverviewMapControl())
|
||||||
|
map.addControl(new BMap.MapTypeControl())
|
||||||
|
},
|
||||||
show: function(event) {
|
show: function(event) {
|
||||||
run(event, ["", "", "cmd", "ssh.data", "show", option.table.value], function(msg) {ctx.Table(msg, function(value) {
|
run(event, ["", "", "cmd", "ssh.data", "show", option.table.value], function(msg) {ctx.Table(msg, function(value) {
|
||||||
kit.Selector(output, ".s"+value[option.when.value].split(" ")[0].split("-").join(""), function(item) {
|
kit.Selector(output, ".s"+value[option.when.value].split(" ")[0].split("-").join(""), function(item) {
|
||||||
@ -56,4 +68,40 @@
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
Search: function() {var plugin = field.Plugin
|
||||||
|
plugin.initMap()
|
||||||
|
var g = new BMap.Geocoder()
|
||||||
|
g.getPoint(option.place.value, function(p) {
|
||||||
|
kit.Log("place", p)
|
||||||
|
if (!p) {alert("not found"); return}
|
||||||
|
map.centerAndZoom(p, option.scale.value)
|
||||||
|
}, option.city.value)
|
||||||
|
},
|
||||||
|
Record: function() {var plugin = field.Plugin
|
||||||
|
var l = map.getCenter()
|
||||||
|
run(event, [option.table.value, option.when.value, option.what.value, option.city.value, option.place.value, l.lng, l.lat, map.getZoom()], function(msg) {
|
||||||
|
console.log("ok")
|
||||||
|
})
|
||||||
|
},
|
||||||
|
Plays: function() {var plugin = field.Plugin
|
||||||
|
plugin.initMap(), run(event, [option.table.value], function(msg) {
|
||||||
|
kit.List(ctx.Table(msg), function(line) {
|
||||||
|
output.style.opacity = 0
|
||||||
|
var p = new BMap.Point(line.longitude, line.latitude)
|
||||||
|
map.centerAndZoom(p, line.scale)
|
||||||
|
|
||||||
|
var info = new BMap.InfoWindow(line.when+"<br/>"+line.place, {width: 200, height: 100, title: line.what})
|
||||||
|
map.openInfoWindow(info, map.getCenter())
|
||||||
|
|
||||||
|
var scales = []
|
||||||
|
for (var i = 0; i < 10; i++) {
|
||||||
|
scales.push(i*0.1)
|
||||||
|
}
|
||||||
|
kit.List(scales, function(scale) {
|
||||||
|
output.style.opacity = scale
|
||||||
|
}, 100)
|
||||||
|
}, 3000)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
}}}
|
}}}
|
||||||
|
@ -24,7 +24,7 @@ kit date "日历" "index.js" "index.css" protected "cli.date" _ nature _ \
|
|||||||
|
|
||||||
fun days "每一天" "index.js" "index.css" protected \
|
fun days "每一天" "index.js" "index.css" protected \
|
||||||
text "days" name table imports plugin_table \
|
text "days" name table imports plugin_table \
|
||||||
text "" name when init date\
|
text "" name when init date \
|
||||||
text "" name what view long \
|
text "" name what view long \
|
||||||
button "记下了" \
|
button "记下了" \
|
||||||
button "记下了" cb Quick
|
button "记下了" cb Quick
|
||||||
@ -36,6 +36,24 @@ fun days "每一天" "index.js" "index.css" protected \
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fun maps "每一面" "index.js" "index.css" protected \
|
||||||
|
text "maps" name table imports plugin_table \
|
||||||
|
text "" name when init date \
|
||||||
|
text "" name what view long \
|
||||||
|
text "北京市" name city \
|
||||||
|
text "弘源首著" name place \
|
||||||
|
text "16" name scale \
|
||||||
|
button "搜索" cb Search \
|
||||||
|
button "记录" cb Record \
|
||||||
|
button "展示" cb Plays
|
||||||
|
|
||||||
|
if $2 == "" || $3 == ""
|
||||||
|
copy skip ssh.data show _
|
||||||
|
else
|
||||||
|
copy ssh.data insert _ when _ what _ city _ place _ longitude _ latitude _ scale _
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
fun delay "以后告诉你" protected \
|
fun delay "以后告诉你" protected \
|
||||||
text "delay" name table imports plugin_table \
|
text "delay" name table imports plugin_table \
|
||||||
text "" name when init date\
|
text "" name when init date\
|
||||||
|
@ -704,6 +704,6 @@ var page = Page({check: true,
|
|||||||
page.onaction[item] && page.onaction[item](event, item, value, page)
|
page.onaction[item] && page.onaction[item](event, item, value, page)
|
||||||
})
|
})
|
||||||
page.river.Pane.Show()
|
page.river.Pane.Show()
|
||||||
page.WSS()
|
// page.WSS()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -734,12 +734,7 @@ function Plugin(page, pane, field, runs) {
|
|||||||
Append: function(item, name, value) {
|
Append: function(item, name, value) {
|
||||||
kit.Item(plugin.onaction, function(k, cb) {
|
kit.Item(plugin.onaction, function(k, cb) {
|
||||||
item[k] == undefined && (item[k] = typeof cb == "function"? function(event) {
|
item[k] == undefined && (item[k] = typeof cb == "function"? function(event) {
|
||||||
try {
|
cb(event, action, item.type, input.name, item)
|
||||||
cb(event, action, item.type, input.name, item)
|
|
||||||
} catch (e) {
|
|
||||||
console.trace()
|
|
||||||
kit.Log("err", e)
|
|
||||||
}
|
|
||||||
}: cb)
|
}: cb)
|
||||||
});
|
});
|
||||||
item.value = plugin.onformat(item.init)(item.value)
|
item.value = plugin.onformat(item.init)(item.value)
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
{{range $index, $lib := option . "scripts"}}
|
{{range $index, $lib := option . "scripts"}}
|
||||||
<script src="/static/librarys/{{$lib}}"></script>
|
<script src="/static/librarys/{{$lib}}"></script>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
<script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak="></script>
|
||||||
</body>
|
</body>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user