bsw/jbe@1309: function ui.field.location(args) bsw/jbe@1309: if config.map then bsw/jbe@1309: ui.form_element(args, {fetch_value = true}, function(args) bsw/jbe@1309: ui.tag{ bsw/jbe@1309: tag = "input", bsw/jbe@1309: attr = { type = "hidden", name = args.name, value = args.value, id = "ui_field_location_value" } bsw/jbe@1309: } bsw/jbe@1309: end) bsw/jbe@1309: ui.map({}, "ui_field_location_value") bsw/jbe@1309: elseif config.firstlife then bsw/jbe@1309: ui.form_element(args, {fetch_value = true}, function(args) bsw/jbe@1309: ui.tag{ bsw/jbe@1309: tag = "input", bsw/jbe@1309: attr = { type = "hidden", name = args.name, value = args.value, id = "ui_field_location_value" } bsw/jbe@1309: } bsw@1519: ui.tag{ bsw@1519: tag = "input", bsw@1519: attr = { type = "hidden", name = args.name .. "_marker_link", value = args.value_marker_link, id = "ui_field_location_marker_link" } bsw@1519: } bsw@1519: 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 = "" } bsw/jbe@1309: bsw/jbe@1309: ui.script{ script = [[ bsw/jbe@1309: bsw/jbe@1309: window.addEventListener("message", function (e) { bsw/jbe@1309: if (e.origin !== "]] .. config.firstlife.inputmap_url .. [[") return; bsw/jbe@1309: var data = e.data; bsw/jbe@1309: if (data.src == "InputMap") { bsw@1519: var feature = { "type": "Point", "coordinates": [data.lng, data.lat], "zoom_level": data.zoom_level }; bsw@1519: if (data.feature) { bsw@1519: feature.marker_link = data.feature.marker_link; bsw@1519: } bsw/jbe@1309: var el = document.getElementById("ui_field_location_value"); bsw@1519: el.value = JSON.stringify(feature); bsw/jbe@1309: } bsw/jbe@1309: }); bsw/jbe@1309: ]] } bsw/jbe@1309: end) bsw/jbe@1309: end bsw/jbe@1309: end