{"id":748,"date":"2017-01-08T16:47:51","date_gmt":"2017-01-08T07:47:51","guid":{"rendered":"http:\/\/blue-bear.jp\/kb\/?p=748"},"modified":"2017-02-10T13:47:39","modified_gmt":"2017-02-10T04:47:39","slug":"swift-geofire%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9f%e4%bd%8d%e7%bd%ae%e6%83%85%e5%a0%b1%e6%9b%b8%e3%81%8d%e8%be%bc%e3%81%bf%e3%80%81%e8%aa%ad%e3%81%bf%e8%be%bc%e3%81%bf","status":"publish","type":"post","link":"https:\/\/blue-bear.jp\/kb\/swift-geofire%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9f%e4%bd%8d%e7%bd%ae%e6%83%85%e5%a0%b1%e6%9b%b8%e3%81%8d%e8%be%bc%e3%81%bf%e3%80%81%e8%aa%ad%e3%81%bf%e8%be%bc%e3%81%bf\/","title":{"rendered":"[swift] GeoFire\u3092\u4f7f\u7528\u3057\u305f\u4f4d\u7f6e\u60c5\u5831\u66f8\u304d\u8fbc\u307f\u3001\u8aad\u307f\u8fbc\u307f"},"content":{"rendered":"<h2>GeoFire\u3092\u4f7f\u7528\u3057\u305f\u4f4d\u7f6e\u60c5\u5831\u66f8\u304d\u8fbc\u307f\u3001\u8aad\u307f\u8fbc\u307f<\/h2>\n<p>\u7279\u5b9a\u306e\u4f4d\u7f6e\u304b\u3089\u3042\u308b\u7bc4\u56f2\u306e\u4f4d\u7f6e\u60c5\u5831\u691c\u7d22\u30e2\u30b8\u30e5\u30fc\u30eb\u300cGeoFire\u300d\u3092\u4f7f\u3063\u305f\u4f4d\u7f6e\u60c5\u5831\u66f8\u304d\u8fbc\u307f\u3001\u8aad\u307f\u8fbc\u307f<\/p>\n<p>GeoFire\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5\u306f\u4ee5\u4e0b\u3092\u53c2\u7167<br \/>\n<a href=\"http:\/\/blue-bear.jp\/kb\/swift-firebase3-x-x-geofire2-x-x-install%e6%96%b9%e6%b3%95%ef%bc%88%e4%bd%8d%e7%bd%ae%e7%af%84%e5%9b%b2%e6%a4%9c%e7%b4%a2%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89%ef%bc%89\/\">[swift] Firebase3.x.x + GeoFire2.x.x Install\u65b9\u6cd5\uff08\u4f4d\u7f6e\u7bc4\u56f2\u691c\u7d22\u30e1\u30bd\u30c3\u30c9\uff09<\/a><\/p>\n<h3>\u4f4d\u7f6e\u60c5\u5831\u66f8\u304d\u8fbc\u307f<\/h3>\n<p>*\u4f8b\u3067\u306flocationInfo\u3068\u3044\u3046\u5834\u6240\u306b\u30c7\u30fc\u30bf\u3092\u4fdd\u5b58\u3057\u3066\u3044\u308b<\/p>\n<pre>\r\n        let latitude: CLLocationDegrees = 1.304843 \/\/Singapore\r\n        let longitude: CLLocationDegrees = 103.831824 \/\/Singapore\r\n        let key: String = \"unique Key\"\r\n        let geofireRef = FIRDatabase.database().reference().child(\"locationInfo\")\r\n        let geoFire = GeoFire(firebaseRef: geofireRef)\r\n        geoFire.setLocation(CLLocation(latitude: latitude, longitude: longitude), forKey: key){ (error) in\r\n            if (error != nil) {\r\n                print(\"An error occurred: \\(error)\")\r\n            } else {\r\n                print(\"Saved location successfully!\")\r\n            }\r\n        }\r\n<\/pre>\n<h3>\u4f4d\u7f6e\u60c5\u5831\u691c\u7d22<\/h3>\n<p>\uff0alocationInfo\u304b\u308910km\u7bc4\u56f2\u3067\u4f4d\u7f6e\u691c\u7d22\u3092\u5b9f\u65bd<br \/>\n*\u691c\u7d22\u304c\u7d42\u4e86\u3059\u308b\u3068query.observeReadyWithBlock\u304c\u547c\u3070\u308c\u308b\u3002<br \/>\n*\u691c\u7d22\u3067\u8fd4\u3063\u3066\u304f\u308b\u30c7\u30fc\u30bf\u306f\u4fdd\u5b58\u3057\u305fKey\u3068CLLocation<\/p>\n<pre>\r\n            let latitude: CLLocationDegrees = 1.304843 \/\/Singapore\r\n            let longitude: CLLocationDegrees = 103.831824 \/\/Singapore\r\n            let radius:Double = 10.0 \/\/km\r\n            let geofireRef = FIRDatabase.database().reference().child(\"courseStart\")\r\n            let geoFire = GeoFire(firebaseRef: locationInfo)\r\n            let center = CLLocation(latitude: latitude, longitude: longitude)\r\n            let query = geoFire.queryAtLocation(center, withRadius: radius)\r\n            query.observeEventType(.KeyEntered, withBlock: { (key: String!, location: CLLocation!) in                \r\n                print(\"Key '\\(key)' entered the search area and is at location '\\(location)'\")\r\n            })\r\n            \r\n            query.observeReadyWithBlock({\r\n                \/\/\u7d42\u4e86\u6642\u306e\u51e6\u7406...\r\n            })\r\n<\/pre>\n<h3>Not a valid geo location for a huge radius\u30a8\u30e9\u30fc<\/h3>\n<p>\u4f4d\u7f6e\u691c\u7d22\u3067\u691c\u7d22\u534a\u5f84\u309223km\u4ee5\u4e0a\u306b\u8a2d\u5b9a\u3059\u308b\u3068<\/p>\n<pre>Not a valid geo location for a huge radius<\/pre>\n<p>\u3068\u3044\u3046\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u306e\u3067\u3001\u691c\u7d22\u7bc4\u56f2\u309223km\u4ee5\u5185\u306b\u3057\u3066\u304a\u304f\u3053\u3068<\/p>\n<p>\u3082\u3057\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u52a3\u5316\u3057\u305f\u3089\u3001\u3001<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"4bPIK11IU6\"><p><a href=\"https:\/\/blue-bear.jp\/kb\/firebase-geofire%e3%81%ae%e3%83%91%e3%83%95%e3%82%a9%e3%83%bc%e3%83%9e%e3%83%b3%e3%82%b9%e5%8a%a3%e5%8c%96%e3%81%a8%e5%af%be%e5%87%a6%e6%96%b9%e6%b3%95\/\">[firebase] GeoFire\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u52a3\u5316\u3068\u5bfe\u51e6\u65b9\u6cd5<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;[firebase] GeoFire\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u52a3\u5316\u3068\u5bfe\u51e6\u65b9\u6cd5&#8221; &#8212; Bluebear I\/O\" src=\"https:\/\/blue-bear.jp\/kb\/firebase-geofire%e3%81%ae%e3%83%91%e3%83%95%e3%82%a9%e3%83%bc%e3%83%9e%e3%83%b3%e3%82%b9%e5%8a%a3%e5%8c%96%e3%81%a8%e5%af%be%e5%87%a6%e6%96%b9%e6%b3%95\/embed\/#?secret=4bPIK11IU6\" data-secret=\"4bPIK11IU6\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>GeoFire\u3092\u4f7f\u7528\u3057\u305f\u4f4d\u7f6e\u60c5\u5831\u66f8\u304d\u8fbc\u307f<\/p>\n","protected":false},"author":1,"featured_media":915,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[73],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/748"}],"collection":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/comments?post=748"}],"version-history":[{"count":3,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/748\/revisions"}],"predecessor-version":[{"id":916,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/748\/revisions\/916"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media\/915"}],"wp:attachment":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media?parent=748"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/categories?post=748"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/tags?post=748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}