{"id":917,"date":"2019-03-11T18:41:09","date_gmt":"2019-03-11T09:41:09","guid":{"rendered":"http:\/\/idealive.jp\/blog\/?p=917"},"modified":"2019-03-11T18:41:20","modified_gmt":"2019-03-11T09:41:20","slug":"%e3%80%90swift4-0%e3%80%91mkmapview%e3%81%a7%e3%83%94%e3%83%b3%e3%82%92%e7%94%bb%e5%83%8f%e3%81%ab%e5%a4%89%e3%81%88%e3%81%a6%e3%81%bf%e3%81%9f","status":"publish","type":"post","link":"https:\/\/idealive.jp\/blog\/2019\/03\/11\/%e3%80%90swift4-0%e3%80%91mkmapview%e3%81%a7%e3%83%94%e3%83%b3%e3%82%92%e7%94%bb%e5%83%8f%e3%81%ab%e5%a4%89%e3%81%88%e3%81%a6%e3%81%bf%e3%81%9f\/","title":{"rendered":"\u3010Swift4.0\u3011MKMapView\u3067\u30d4\u30f3\u3092\u753b\u50cf\u306b\u5909\u3048\u3066\u307f\u305f"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3000sohnishi\u3000\u3067\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306fMKMapView\u3067\u30d4\u30f3\u3092\u8868\u793a\u3055\u305b\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30d4\u30f3\u3092\u753b\u50cf\u306b\u5909\u3048\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \" title=\"mapview.swift\">func setMapPin(latitude: CLLocationDegrees, longitude: CLLocationDegrees) {\r\n        \r\n        \/\/ pin\u751f\u6210\r\n        let pin = MKPointAnnotation()\r\n        \r\n        \/\/ \u4f4d\u7f6e\u60c5\u5831\r\n        let coordinate: CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude,longitude)\r\n        \r\n        \/\/ pin\u306b\u4f4d\u7f6e\u60c5\u5831\u3092\u6e21\u3059\r\n        pin.coordinate = coordinate\r\n        \r\n        \/\/pin\u3092\u7acb\u3066\u308b\r\n        mapView.addAnnotation(pin)\r\n    }\r\n\r\n    \/\/addAnnotation\u3057\u305f\u969b\u306b\u547c\u3070\u308c\u308b\u30c7\u30ea\u30b2\u30fc\u30c8\u30e1\u30bd\u30c3\u30c9\r\n    func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -&gt; MKAnnotationView? {\r\n        let identifier = \"pin\"\r\n        var annotationView: MKAnnotationView!\r\n\r\n        if annotationView == nil {\r\n            annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: identifier)\r\n        }\r\n\r\n        \/\/ pin\u306b\u8868\u793a\u3059\u308b\u753b\u50cf\u3092\u6307\u5b9a\r\n        annotationView.image = UIImage(named: \" hoge_pin_img\")!\r\n        annotationView.annotation = annotation\r\n        annotationView.canShowCallout = true\r\n\r\n        return annotationView\r\n    }<\/pre>\n<p>\u4ee5\u4e0a\u3067\u3059\u3002<br \/>\n\u307e\u305a\u306f\u3001\u6307\u5b9a\u5ea7\u6a19\u306bpin\u3092\u7acb\u3066\u3066\u3001\u30c7\u30ea\u30b2\u30fc\u30c8\u30e1\u30bd\u30c3\u30c9\u5185\u3067\u4efb\u610f\u306e\u753b\u50cf\u3092\u6307\u5b9a\u3057\u3066\u3042\u3052\u307e\u3059\u3002<br \/>\n\u30c7\u30ea\u30b2\u30fc\u30c8\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3048\u3070\u3001pin\u3092\u30bf\u30c3\u30d7\u3055\u308c\u305f\u6642\u306b\u753b\u50cf\u3092\u5909\u3048\u3066\u3042\u3052\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3000sohnishi\u3000\u3067\u3059\u3002 \u4eca\u56de\u306fMKMapView\u3067\u30d4\u30f3\u3092\u8868\u793a\u3055\u305b\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30d4\u30f3\u3092\u753b\u50cf\u306b\u5909\u3048\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002 func setMapPin(latitude: CLLocationDegrees, l&#8230;<a class=\"read-more-link button\" href=\"https:\/\/idealive.jp\/blog\/2019\/03\/11\/%e3%80%90swift4-0%e3%80%91mkmapview%e3%81%a7%e3%83%94%e3%83%b3%e3%82%92%e7%94%bb%e5%83%8f%e3%81%ab%e5%a4%89%e3%81%88%e3%81%a6%e3%81%bf%e3%81%9f\/\">\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":3,"featured_media":772,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,1],"tags":[],"class_list":["post-917","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-swift","category-1"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/posts\/917"}],"collection":[{"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/comments?post=917"}],"version-history":[{"count":2,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/posts\/917\/revisions"}],"predecessor-version":[{"id":919,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/posts\/917\/revisions\/919"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/media\/772"}],"wp:attachment":[{"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/media?parent=917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/categories?post=917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/tags?post=917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}