Last active
November 17, 2017 12:34
-
-
Save r3-yamauchi/4b96d61a8c11d83c2c010d78b6d095e4 to your computer and use it in GitHub Desktop.
Google Pickerを使って場所(緯度・経度)を選択させる https://blog.r3it.com/google-picker-map-81ad931d5bd0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import React from "react"; | |
import { render } from "react-dom"; | |
import Picker from "./Picker"; | |
(function () { | |
kintone.events.on(["app.record.create.show", "app.record.edit.show"], (event: Kintone.RecordEvent) => { | |
const elm = kintone.app.record.getSpaceElement("space1"); | |
if (!elm) { | |
return event; | |
} | |
const picked = data => { | |
if (data && data.action === "picked" && data.docs && data.docs[0]) { | |
const doc = data.docs[0]; | |
const item = kintone.app.record.get(); | |
item.record["緯度"]["value"] = doc.latitude || ""; | |
item.record["経度"]["value"] = doc.longitude || ""; | |
item.record["name"]["value"] = doc.name || ""; | |
item.record["url"]["value"] = doc.url || ""; | |
item.record["address"]["value"] = (doc.addressLines && doc.addressLines[0]) ? doc.addressLines[0] : ""; | |
kintone.app.record.set(item); | |
} | |
}; | |
render( | |
<Picker onChange={picked} />, | |
elm | |
); | |
return event; | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment