Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GeoLocationAnchor and MKTileOverlay

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

GeoLocationAnchor and MKTileOverlay

Avatar for Tachibana Kaoru

Tachibana Kaoru

June 22, 2022
Tweet

More Decks by Tachibana Kaoru

Other Decks in Technology

Transcript

  1. GeoLocation : check availability var targetLocation = CLLocationCoordinate2D() targetLocation.latitude =

    lat targetLocation.longitude = long ARGeoTrackingConfiguration.checkAvailability( at: targetLocation, completionHandler: { (available, error) in // check available })
  2. GeoLocation : check availability available ͕ trueͷ৔߹ʹ͸࢖༻Մೳɻ available ͕ falseͷ৔߹ʹ͸࢖༻ෆՄೳ͕ͩɺΤϥʔίʔυͰཧ༝Λ֬ೝ

    ͢Δ͜ͱ Error Code = 201 "Geo tracking is not available at this location." Error Code = 501 "Request failed." ʢϦΫΤετස౓͕ߴ͍ͱൃੜʣ
  3. λΠϧͱ͸ʁ ஍ਤΛ zoom level ʹԠͯ͡෼ׂ͠ɺͦΕΛඞཁʹԠͯ͡഑৴ɾར༻͢Δɻ zoom level 0 -> 1

    tile zoom level 1 -> 4 tiles zoom level 2 -> 16 tiles ... zoom level 10 -> 1048576 tiles zoom level n -> (2^n)^2
  4. Longitude to x ܦ౓ͰTileͷx͕ܾ·Δ zoom level 2 -> 16 tiles

    longitude = 135.0 ܦ౓0Λج४ͱ͠ɺٿ໘Λ 8෼ׂ͢Δ 0 long = 0 1 2 3 4 5 6 7 long = 135 ๺͔ΒΈͨ஍ٿ
  5. Latitude to y Ң౓ͰTileͷy͕ܾ·Δ zoom level 2 -> 16 tiles

    latitude = 35.0 ๺ۃΛج४ͱ͠ɺٿ໘Λ8 ෼ׂ͢Δ 5 1 2 3 4 0 6 7 lat = 35 ԣ͔ΒΈͨ஍ٿ
  6. let res = initialResolution / pow(2,zoom) let originShift = 2

    * Double.pi * 6378137 / 2.0 var my = log( tan((90 + lat) * Double.pi / 360.0 )) / (Double.pi / 180.0) let py = (my + self.originShift) / res let tms_y = Int( ceil( py / Double(self.tileSize) ) - 1 ) let google_y = Int(pow(2, zoom) - 1 ) - tms_y ignore y = Rln(tan( π 4 + ϕ 2 )) 85.1°