liquid_feedback_frontend
view env/ui/field/location.lua @ 1519:056bccb61eee
Added object reference for geo references
author | bsw |
---|---|
date | Thu Aug 20 15:08:00 2020 +0200 (2020-08-20) |
parents | 32cc544d5a5b |
children |
line source
1 function ui.field.location(args)
2 if config.map then
3 ui.form_element(args, {fetch_value = true}, function(args)
4 ui.tag{
5 tag = "input",
6 attr = { type = "hidden", name = args.name, value = args.value, id = "ui_field_location_value" }
7 }
8 end)
9 ui.map({}, "ui_field_location_value")
10 elseif config.firstlife then
11 ui.form_element(args, {fetch_value = true}, function(args)
12 ui.tag{
13 tag = "input",
14 attr = { type = "hidden", name = args.name, value = args.value, id = "ui_field_location_value" }
15 }
16 ui.tag{
17 tag = "input",
18 attr = { type = "hidden", name = args.name .. "_marker_link", value = args.value_marker_link, id = "ui_field_location_marker_link" }
19 }
20 ui.tag{ tag = "iframe", attr = { src = config.firstlife.inputmap_url .. "/src/index.html?domain=" .. request.get_absolute_baseurl() .. "&" .. config.firstlife.coordinates .. "&lightArea=false&contrast=false&mode=lite&onlypointer=false", id = "ui_field_location", class = "ui_field_location" }, content = "" }
22 ui.script{ script = [[
24 window.addEventListener("message", function (e) {
25 if (e.origin !== "]] .. config.firstlife.inputmap_url .. [[") return;
26 var data = e.data;
27 if (data.src == "InputMap") {
28 var feature = { "type": "Point", "coordinates": [data.lng, data.lat], "zoom_level": data.zoom_level };
29 if (data.feature) {
30 feature.marker_link = data.feature.marker_link;
31 }
32 var el = document.getElementById("ui_field_location_value");
33 el.value = JSON.stringify(feature);
34 }
35 });
36 ]] }
37 end)
38 end
39 end