Flutter-geolocator: λΈŒλΌμš°μ €λ₯Ό 톡해 μ‚¬μš©μž μœ„μΉ˜ κ°€μ Έμ˜€κΈ°

에 λ§Œλ“  2020λ…„ 02μ›” 13일  Β·  32μ½”λ©˜νŠΈ  Β·  좜처: Baseflow/flutter-geolocator

μ•ˆλ…•ν•˜μ„Έμš”, 이 ν”ŒλŸ¬κ·ΈμΈμ΄ λΈŒλΌμš°μ €λ₯Ό 톡해 μ‚¬μš©μžμ˜ μœ„μΉ˜λ₯Ό ​​얻을 수 μžˆλŠ”μ§€ κΆκΈˆν•©λ‹ˆλ‹€. λ‚˜λŠ” 그것에 λŒ€ν•œ 정보λ₯Ό 찾지 λͺ»ν–ˆμŠ΅λ‹ˆκΉŒ? 그것을 ν—ˆμš©ν•˜λŠ” λ‹€λ₯Έ ν”ŒλŸ¬κ·ΈμΈμ΄ μžˆμŠ΅λ‹ˆκΉŒ? 도움을 μ£Όμ…”μ„œ 미리 κ°μ‚¬λ“œλ¦½λ‹ˆλ‹€!

web enhancement

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

@mvanbeusekom 방법을 배울 μ‹œκ°„μ΄ μžˆλ‹€λ©΄ μ‹œλ„ν•΄ λ³Ό 수 μžˆμŠ΅λ‹ˆλ‹€. μ§€κΈˆμ€ js νŒ¨ν‚€μ§€λ₯Ό 톡해 이λ₯Ό μˆ˜ν–‰ν•˜λŠ” 방법을 μ°Ύμ•˜μŠ΅λ‹ˆλ‹€. λˆ„κ΅°κ°€κ°€ μ¦‰μ‹œ μ½”λ“œλ₯Ό μ›ν•˜λ©΄ 여기에 λΉ λ₯΄κ²Œ μ½”λ“œλ₯Ό κ²Œμ‹œν•©λ‹ˆλ‹€.

@JS('navigator.geolocation') // navigator.geolocation namespace
library jslocation; // library name can be whatever you want

import "package:js/js.dart";

@JS('getCurrentPosition') // Accessing method getCurrentPosition from Geolocation API
external void getCurrentPosition(Function success(GeolocationPosition pos));

@JS()
<strong i="7">@anonymous</strong>
class GeolocationCoordinates {
  external double get latitude;
  external double get longitude;
  external double get altitude;
  external double get accuracy;
  external double get altitudeAccuracy;
  external double get heading;
  external double get speed;

  external factory GeolocationCoordinates(
      {double latitude,
      double longitude,
      double altitude,
      double accuracy,
      double altitudeAccuracy,
      double heading,
      double speed});
}

@JS()
<strong i="8">@anonymous</strong>
class GeolocationPosition {
  external GeolocationCoordinates get coords;

  external factory GeolocationPosition({GeolocationCoordinates coords});
}

And to call this :  

  success(pos) {
    try {
    print(pos.coords.latitude);
    print(pos.coords.longitude);
    } catch (ex) {
      print("Exception thrown : " + ex.toString());
    }
  }
  _getCurrentLocation() {
    if (kIsWeb) {
      getCurrentPosition(allowInterop((pos) => success(pos)));
    }

_getCurrentLocation λ©”μ†Œλ“œλ₯Ό ν˜ΈμΆœν•˜κΈ°λ§Œ ν•˜λ©΄ λ©λ‹ˆλ‹€.

λͺ¨λ“  32 λŒ“κΈ€

μ•ˆλ…•ν•˜μ„Έμš” @lionelquirynen , ν˜„μž¬ μ›Ή ν”Œλž«νΌμ— λŒ€ν•œ κ΅¬ν˜„μ΄ μ—†μŠ΅λ‹ˆλ‹€. μš°λ¦¬λŠ” 이것을 μ§€μ›ν•˜κ³  ν’€ λ¦¬ν€˜μŠ€νŠΈλ₯Ό μœ„ν•΄ μ—΄λ € μžˆμŠ΅λ‹ˆλ‹€.

ν–₯ν›„ μ°Έμ‘°λ₯Ό μœ„ν•΄ ν”ŒλŸ¬κ·ΈμΈμ— μ›Ή 지원을 μΆ”κ°€ν•˜λŠ” 방법을 μ„€λͺ…ν•˜λŠ” Flutter νŒ€μ˜ 두 기사가 μžˆμŠ΅λ‹ˆλ‹€.

@mvanbeusekom 방법을 배울 μ‹œκ°„μ΄ μžˆλ‹€λ©΄ μ‹œλ„ν•΄ λ³Ό 수 μžˆμŠ΅λ‹ˆλ‹€. μ§€κΈˆμ€ js νŒ¨ν‚€μ§€λ₯Ό 톡해 이λ₯Ό μˆ˜ν–‰ν•˜λŠ” 방법을 μ°Ύμ•˜μŠ΅λ‹ˆλ‹€. λˆ„κ΅°κ°€κ°€ μ¦‰μ‹œ μ½”λ“œλ₯Ό μ›ν•˜λ©΄ 여기에 λΉ λ₯΄κ²Œ μ½”λ“œλ₯Ό κ²Œμ‹œν•©λ‹ˆλ‹€.

@JS('navigator.geolocation') // navigator.geolocation namespace
library jslocation; // library name can be whatever you want

import "package:js/js.dart";

@JS('getCurrentPosition') // Accessing method getCurrentPosition from Geolocation API
external void getCurrentPosition(Function success(GeolocationPosition pos));

@JS()
<strong i="7">@anonymous</strong>
class GeolocationCoordinates {
  external double get latitude;
  external double get longitude;
  external double get altitude;
  external double get accuracy;
  external double get altitudeAccuracy;
  external double get heading;
  external double get speed;

  external factory GeolocationCoordinates(
      {double latitude,
      double longitude,
      double altitude,
      double accuracy,
      double altitudeAccuracy,
      double heading,
      double speed});
}

@JS()
<strong i="8">@anonymous</strong>
class GeolocationPosition {
  external GeolocationCoordinates get coords;

  external factory GeolocationPosition({GeolocationCoordinates coords});
}

And to call this :  

  success(pos) {
    try {
    print(pos.coords.latitude);
    print(pos.coords.longitude);
    } catch (ex) {
      print("Exception thrown : " + ex.toString());
    }
  }
  _getCurrentLocation() {
    if (kIsWeb) {
      getCurrentPosition(allowInterop((pos) => success(pos)));
    }

_getCurrentLocation λ©”μ†Œλ“œλ₯Ό ν˜ΈμΆœν•˜κΈ°λ§Œ ν•˜λ©΄ λ©λ‹ˆλ‹€.

@lionelquirynen pubspec.yaml 을 κ²Œμ‹œν•  수 μžˆμŠ΅λ‹ˆκΉŒ? λ‹€μŒ 행을 μΆ”κ°€ν•˜λ €κ³  ν•©λ‹ˆλ‹€. import ' package:Shared/locationJs.dart '; stackexchange 에 κ²Œμ‹œν–ˆμ§€λ§Œ 였λ₯˜κ°€ λ°œμƒν•©λ‹ˆλ‹€. 루트 μˆ˜μ€€μ—μ„œ 곡유 폴더λ₯Ό μƒμ„±ν–ˆμŠ΅λ‹ˆκΉŒ?

μ•ˆλ…•ν•˜μ„Έμš” @lionelquirynenμž…λ‹ˆλ‹€!

λ¨Όμ € 여기에 μ†”λ£¨μ…˜μ„ κ²Œμ‹œν•΄ μ£Όμ…”μ„œ κ°μ‚¬ν•©λ‹ˆλ‹€. λ‹Ήμ‹ μ˜ λ©”μ‹œμ§€λ‘œ λ§Žμ€ μ‚¬λžŒλ“€μ—κ²Œ 도움이 된 것 κ°™μ•„μš”!

κ·ΈλŸ¬λ‚˜ λ‚˜λŠ” μ—¬μ „νžˆ 두 가지 질문이 μžˆμ—ˆλ‹€. 당신은 λ˜ν•œ μ΄λŸ¬ν•œ 문제λ₯Ό κ²ͺμ—ˆκ³  이미 해결책을 가지고 μžˆμ„ 수 μžˆμŠ΅λ‹ˆλ‹€.
λ‚΄ μ§ˆλ¬Έμ€ λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

1.) μ›Ήμ‚¬μ΄νŠΈ λ°©λ¬Έμžμ—κ²Œ μœ„μΉ˜λ₯Ό 쿼리할 수 μžˆλŠ” κΆŒν•œμ„ μš”μ²­ν•˜λŠ” 방법을 이미 μ°Ύμ•˜μŠ΅λ‹ˆκΉŒ?
μ•±μ˜ 경우 AndroidManifest.xmlμ—μ„œ Android용으둜, info.plistμ—μ„œ iOS용으둜 이 μž‘μ—…μ„ μˆ˜ν–‰ν•©λ‹ˆλ‹€. κ·ΈλŸ¬λ‚˜ μ›Ή μ‘μš© ν”„λ‘œκ·Έλž¨μ—μ„œλŠ” μ–΄λ–»κ²Œ ν•΄μ•Ό ν•©λ‹ˆκΉŒ?

2.) 두 점 μ‚¬μ΄μ˜ 거리λ₯Ό λ―Έν„° λ‹¨μœ„λ‘œ κ³„μ‚°ν•˜λŠ” ν•¨μˆ˜λ₯Ό 이미 κ΅¬μΆ•ν–ˆμŠ΅λ‹ˆκΉŒ?

당신이 λŒ€λ‹΅ν•œλ‹€λ©΄ λ‚˜λŠ” ν™•μ‹€νžˆ 기쁠 κ²ƒμž…λ‹ˆλ‹€! 당신은 λ‚˜μ—κ²Œ λ§Žμ€ 도움이 될 κ²ƒμž…λ‹ˆλ‹€!

@xpat λ„€, locationJs 파일이 μžˆλŠ” 폴더가 μžˆμŠ΅λ‹ˆλ‹€. μ£„μ†‘ν•©λ‹ˆλ‹€. μ˜€λŠ˜μ—μ„œμ•Ό λ‹Ήμ‹ μ˜ λ©”μ‹œμ§€λ₯Ό λ³΄μ•˜μŠ΅λ‹ˆλ‹€.
pubspec의 경우 아무 것도 λ³€κ²½λ˜μ§€ μ•ŠμœΌλ©° js νŒ¨ν‚€μ§€λ₯Ό μΆ”κ°€ν•˜κΈ°λ§Œ ν•˜λ©΄ λ©λ‹ˆλ‹€.

@LarsHenning98
μ•ˆλ…•,

1) μ œκ°€ 올린 μ½”λ“œλ‘œ 웹에 κΆŒν•œμ„ μš”μ²­ν•˜λ‹ˆ 잘 λ©λ‹ˆλ‹€! μ›Ήμš©μœΌλ‘œ 이 μ½”λ“œλ₯Ό μ‚¬μš©ν•˜λ©΄ μžλ™μœΌλ‘œ κΆŒν•œμ„ μš”μ²­ν•©λ‹ˆλ‹€. μ›ν•˜λŠ” 경우 λ‚΄ λͺ¨μ˜ ν”„λ‘œμ νŠΈμ—μ„œ μ‹œλ„ν•΄ λ³Ό 수 μžˆμŠ΅λ‹ˆλ‹€. https://www.nearysport.com/
2) 예, ν•˜μ§€λ§Œ μ„œλ²„ μΈ‘, ν΄λΌμ΄μ–ΈνŠΈ μΈ‘μ—μ„œ μ‚¬μš©μžλ‘œλΆ€ν„° μœ„λ„μ™€ 경도λ₯Ό κ²€μƒ‰ν•œ λ‹€μŒ Haversine 곡식과 같은 두 지리적 μœ„μΉ˜ μ‚¬μ΄μ˜ 거리λ₯Ό 계산해야 ν•©λ‹ˆλ‹€.

λ‚΄κ°€ λ‹Ήμ‹ μ˜ μ§ˆλ¬Έμ— λŒ€λ‹΅ν–ˆλ‹€λ©΄ μ•Œλ €μ£Όμ„Έμš”!

@lionelquirynen κ°μ‚¬ν•©λ‹ˆλ‹€. μˆ˜μ—… ν”„λ‘œμ νŠΈμ—μ„œ 이 μž‘μ—…μ„ μˆ˜ν–‰ν•˜λŠ” 방법을 μ°ΎκΈ° μœ„ν•΄ μ—¬κΈ°μ €κΈ° λŒμ•„λ‹€λ‹ˆκ³  μžˆμŠ΅λ‹ˆλ‹€. pubspec.yaml이 μž‘λ™ν•˜κ³  loading_screen.dart νŒŒμΌμ— locationJS.dart νŒŒμΌμ„ κ°€μ Έμ™”μŠ΅λ‹ˆλ‹€. μ–΄μ¨Œλ“  이 μž‘μ—…μ„ μˆ˜ν–‰ν•˜λŠ” 방법을 μ‰½κ²Œ μ•Œ 수 μžˆμŠ΅λ‹ˆλ‹€. κ·Έ λ™μ•ˆ λ‚˜λŠ” 계속 연결을 λŠμ„ κ²ƒμž…λ‹ˆλ‹€. μˆ˜μ—… κ²Œμ‹œνŒμ— κ²Œμ‹œν•œ λ©”μ‹œμ§€ λ§ν¬μž…λ‹ˆλ‹€. https://www.appbrewery.co/courses/548873/lectures/9989052/comments/5326630

참고 둜 @LarsHenning98

pubspecκ³Ό λ‘œλ”© 화면을 κ²Œμ‹œν•  수 μžˆμŠ΅λ‹ˆκΉŒ?

@lionelquirynen 예, pubspec: `이름: clima
μ„€λͺ…: μƒˆλ‘œμš΄ Flutter μ• ν”Œλ¦¬μΌ€μ΄μ…˜μž…λ‹ˆλ‹€.

version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2
  geolocator: ^5.3.0
  js: ^0.6.1+1

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: true

  assets:
  - images/

  fonts:
  - family: Spartan MB
    fonts:
    - asset: fonts/SpartanMB-Black.otf
      weight: 900`

@lionelquirynen 및 loading_screen.dart:

import 'dart:developer';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:clima/locationJS.dart';
import 'package:js/js.dart';

class LoadingScreen extends StatefulWidget {
  <strong i="7">@override</strong>
  _LoadingScreenState createState() => _LoadingScreenState();
}

class _LoadingScreenState extends State<LoadingScreen> {
  void getCurrentPosition() async {
    Position position = await Geolocator()
        .getCurrentPosition(desiredAccuracy: LocationAccuracy.low);

    print(position);
  }

  <strong i="8">@override</strong>
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: RaisedButton(
          onPressed: () {
// Get the current location
          },
          child: Text('Get Location'),
        ),
      ),
    );
  }
}

λ©”μ„œλ“œλ₯Ό ν˜ΈμΆœν•˜μ§€ μ•ŠλŠ” μ΄μœ λŠ” InitState에 λ„£μ–΄μ•Ό ν•˜λŠ” μ΄μœ μž…λ‹ˆλ‹€.

@lionelquirynen 도움을 μ£Όμ…”μ„œ κ°μ‚¬ν•©λ‹ˆλ‹€. λ‚˜λŠ” λ‹Ήμ‹ (λ˜λŠ” λ‹€λ₯Έ μ‚¬λžŒ)μ—κ²Œ μ˜μ‘΄ν•΄μ•Ό ν•˜λŠ” 것을 μ‹«μ–΄ν•˜μ§€λ§Œ, μ–΄λ–€ νŒŒμΌμ„ λ„£κ±°λ‚˜ ν˜ΈμΆœν•΄μ•Ό 할지 μ—¬μ „νžˆ ν˜Όλž€μŠ€λŸ½μŠ΅λ‹ˆλ‹€. λ‹€μŒμ€ 전체 ν”„λ‘œμ νŠΈμ— λŒ€ν•œ λ§ν¬μž…λ‹ˆλ‹€. . 그리고 이것은 λΆˆν–‰νžˆλ„ flutter web 이전에 λ§Œλ“€μ–΄μ§„ Complete Flutter Development Bootcamp의 13번째 λͺ¨λ“ˆμ—μ„œ κ°€μ Έμ˜¨ κ²ƒμž…λ‹ˆλ‹€.

λ©”μ„œλ“œ 호좜이 어디에도 ν‘œμ‹œλ˜μ§€ μ•ŠκΈ° λ•Œλ¬Έμ— onpressedμ—μ„œ getcurrentposition λ©”μ„œλ“œλ₯Ό ν˜ΈμΆœν•  수 μžˆμŠ΅λ‹ˆλ‹€. μœ„μΉ˜ μš”μ²­μ„ νŠΈλ¦¬κ±°ν•˜λ €λ©΄ μ–΄λ”˜κ°€μ—μ„œ ν˜ΈμΆœν•΄μ•Ό ν•©λ‹ˆλ‹€.

그게 λ‚΄κ°€ λ§‰νžˆλŠ” 곳이야. λ‚΄κ°€ λ‹Ήμ‹ μ˜ μ œμ•ˆμ„ μ΄ν•΄ν•˜λŠ” 방식을 기반으둜 λ‚΄κ°€ μ‹œλ„ν•˜λŠ” 것을 μ‚΄νŽ΄λ³΄κ³  싢은 경우λ₯Ό λŒ€λΉ„ν•˜μ—¬ 방금 loading_screen.dart νŒŒμΌμ„ μ—…λ°μ΄νŠΈν–ˆμŠ΅λ‹ˆλ‹€. Dart Analysisμ—μ„œ λ‹€μŒκ³Ό 같은 정보 λ©”μ‹œμ§€κ°€ λ‚˜νƒ€λ‚©λ‹ˆλ‹€. "' getCurrentPosition' 선언이 μ°Έμ‘°λ˜μ§€ μ•Šκ³  js.dart 및 clima/locationJS.dart νŒ¨ν‚€μ§€κ°€ μ‚¬μš©λ˜μ§€ μ•Šκ³  print(value.coords.latitude) ) 및 print(value.coords.longitude)λŠ” νšŒμƒ‰ λ¬Όκ²°μ„  밑쀄이 κ·Έμ–΄μ Έ 있고 "μ„ΈνŠΈ λ¦¬ν„°λŸ΄μ€ 버전 2.2κΉŒμ§€ μ§€μ›λ˜μ§€ μ•Šμ•˜μ§€λ§Œ 이 μ½”λ“œλŠ” 이전 λ²„μ „μ—μ„œ μ‹€ν–‰ν•  수 μžˆμ–΄μ•Ό ν•©λ‹ˆλ‹€."λΌλŠ” λ©”μ‹œμ§€κ°€ ν‘œμ‹œλ©λ‹ˆλ‹€.

locationjsκ°€ μ΅œμ‹  μƒνƒœμž…λ‹ˆκΉŒ?

λ‚˜λŠ” 당신이 stackoverflow 에 κ²Œμ‹œν•œ μ½”λ“œλ₯Ό μ‚¬μš©ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. 그게 당신이 μ˜λ―Έν•˜λŠ” λ°”μΈκ°€μš”? λ‚˜λŠ” λ‹€μ‹œ flutter pub get을 μš΄μ˜ν•  κ²ƒμ΄μ§€λ§Œ, 예, μ΅œμ‹  μƒνƒœλΌκ³  μƒκ°ν•©λ‹ˆλ‹€.

stackoverflowκ°€ μ•„λ‹Œ ​​github의 μ½”λ“œλ₯Ό λΆ™μ—¬λ„£μœΌμ…¨λ‚˜μš”?

λ₯΄ λ²€. 28μ—΄ 2020 Γ  21:53, Christophe R. Patraldo <
[email protected]> μ—ν¬λ¦¬νŠΈ:

λ‚˜λŠ” λ‹€μ‹œ flutter pub get을 μš΄μ˜ν•  κ²ƒμ΄μ§€λ§Œ, 예, μ΅œμ‹  μƒνƒœλΌκ³  μƒκ°ν•©λ‹ˆλ‹€.

β€”
당신이 μ–ΈκΈ‰λ˜μ—ˆκΈ° λ•Œλ¬Έμ— 이것을 λ°›λŠ” κ²ƒμž…λ‹ˆλ‹€.
이 이메일에 직접 λ‹΅μž₯ν•˜κ³  GitHubμ—μ„œ ν™•μΈν•˜μ„Έμš”.
https://github.com/Baseflow/flutter-geolocator/issues/392?email_source=notifications&email_token=ANUIRZMOEPTHHNBI7NDU3G3RFF2TJA5CNFSM4KURNFD2YYY3PNVWWK3TUL52HS4DFVEXG43VMVBW63
λ˜λŠ” ꡬ독 μ·¨μ†Œ
https://github.com/notifications/unsubscribe-auth/ANUIRZLLEKQ2CKHF2A7VUIDRFF2TJANCNFSM4KURNFDQ
.

λ‚΄ 말은 .dart

μœ„μ˜ github에 κ²Œμ‹œν•œ μ½”λ“œλ₯Ό μ‚¬μš©ν•΄μ•Ό ν•©λ‹ˆλ‹€. stackoverflow에 λŒ€ν•œ 닡변을 μ—…λ°μ΄νŠΈν•΄μ•Ό ν•©λ‹ˆλ‹€.

μ΄ν•΄ν•˜κΈ° 쉽기 λ•Œλ¬Έμ— stackoverflow μ½”λ“œμ— μ§‘μ€‘ν–ˆμŠ΅λ‹ˆλ‹€. ν•˜μ§€λ§Œ 이제 Github의 μ½”λ“œλ‘œ loading_screen.dart 및 locationJS.dart νŒŒμΌμ„ μ—…λ°μ΄νŠΈν–ˆμŠ΅λ‹ˆλ‹€. '_LoadingScreenState' ν΄λž˜μŠ€μ— λŒ€ν•΄ 'success' λ©”μ„œλ“œκ°€ μ •μ˜λ˜μ§€ μ•Šμ•˜κ³  '_LoadingScreenState' ν΄λž˜μŠ€μ— λŒ€ν•΄ '_getCurrentLocation' λ©”μ„œλ“œκ°€ μ •μ˜λ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€.

@JS('navigator.geolocation')
library jslocation;

import 'package:js/js.dart';

@JS('getCurrentPosition')
external void getPosition(Function success(GeolocationPosition pos));

@JS()
<strong i="6">@anonymous</strong>
class GeolocationCoordinates {
  external double get latitude;
  external double get longitude;
  external double get altitude;
  external double get accuracy;
  external double get altitudeAccuracy;
  external double get heading;
  external double get speed;
  external factory GeolocationCoordinates(
  {double latitude,
  double longitude,
  double altitude,
  double accuracy,
  double altitudeAccuracy,
  double heading,
  double speed});
}

@JS()
<strong i="7">@anonymous</strong>
class GeolocationPosition {
  external GeolocationCoordinates get coords;

  external factory GeolocationPosition({GeolcationCoordinates});
}
import 'dart:developer';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:clima/locationJS.dart';
import 'package:js/js.dart';

class LoadingScreen extends StatefulWidget {
  <strong i="5">@override</strong>
  _LoadingScreenState createState() => _LoadingScreenState();
}

class _LoadingScreenState extends State<LoadingScreen> {
  void getCurrentPosition() async {
      success(pos);
      try
          {
            print(pos.coords.latitude);
            print(pos.coords.longitude);
          } catch (ex) {
        print("Exception thrown: " + ex.toString());
      }
    }

  <strong i="6">@override</strong>
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: RaisedButton(
          onPressed: () {
// Get the current location
         _getCurrentLocation();

          },
          child: Text('Get Location'),
        ),
      ),
    );
  }
}

μ‚¬μš© 방법은 githubμ—μ„œ λ‚΄ μ½”λ“œλ₯Ό μ°Έμ‘°ν•˜μ„Έμš”.

λ‚΄κ°€ λ°›λŠ” 였λ₯˜λŠ” Github(μœ„)에 κ²Œμ‹œν•œ μ½”λ“œλ₯Ό μ‚¬μš©ν•œ ν›„ λ°œμƒν•©λ‹ˆλ‹€. λ‚˜λŠ” κ·Έ μ½”λ“œλ₯Ό λ‚΄ ν”„λ‘œμ νŠΈμ— μ •ν™•νžˆ μ–΄λ–»κ²Œ μΆ”κ°€ν•΄μ•Ό 할지 λͺ°λΌ ν—€λ§ΈμŠ΅λ‹ˆλ‹€. 예λ₯Ό λ“€μ–΄, μ„±κ³΅μœΌλ‘œ μ‹œμž‘ν•˜λŠ” 뢀뢄을 어디에 λ„£λ‚˜μš”? 여기에 λ„£μ–΄ λ³΄μ•˜μŠ΅λ‹ˆλ‹€.

클래슀 _LoadingScreenState ν™•μž₯ μƒνƒœ {
무효 getCurrentPosition() 비동기 {
성곡(ν¬μ§€μ…˜);
λ…Έλ ₯ν•˜λ‹€
{

전체 ν”„λ‘œμ νŠΈ μ½”λ“œκ°€ ν¬ν•¨λœ 곡개 리포지토리가 μžˆμŠ΅λ‹ˆκΉŒ?

μ•„λ‹ˆμš”, κ³΅κ°œλ˜μ§€λŠ” μ•Šμ•˜μ§€λ§Œ μœ„μ— μ½”λ“œλ₯Ό κ²Œμ‹œν–ˆμŠ΅λ‹ˆλ‹€.

성곡(ν¬μ§€μ…˜) {
λ…Έλ ₯ν•˜λ‹€ {
인쇄(pos.coords.latitude);
인쇄(pos.coords.longitude);
} 작기(μ˜ˆμ‹œ) {
print("μ˜ˆμ™Έ λ°œμƒ: " + ex.toString());
}
}
_getCurrentLocation() {
if (kIsWeb) {
getCurrentPosition(allowInterop((pos) => 성곡(pos)));
}또 λ‹€λ₯Έ{
// μœ„μΉ˜ κ°€μ Έμ˜€κΈ° Ios Android
}
}

λ”°λΌμ„œ 이 μ½”λ“œλ₯Ό λ³΅μ‚¬ν•˜μ—¬ λΆ™μ—¬λ„£κ³  onPressed λ©”μ„œλ“œμ—μ„œ _getCurrentLocation()을 ν˜ΈμΆœν•˜κΈ°λ§Œ ν•˜λ©΄ λ©λ‹ˆλ‹€.

이 μ½”λ“œλŠ” locationJS.dart νŒŒμΌμ΄λ‚˜ loading_screen.dart에 λ“€μ–΄κ°€λ‚˜μš”?

`그리고 이것을 ν˜ΈμΆœν•˜λ €λ©΄ :

성곡(ν¬μ§€μ…˜) {
λ…Έλ ₯ν•˜λ‹€ {
인쇄(pos.coords.latitude);
인쇄(pos.coords.longitude);
} 작기(μ˜ˆμ‹œ) {
print("μ˜ˆμ™Έ λ°œμƒ: " + ex.toString());
}
}
_getCurrentLocation() {
if (kIsWeb) {
getCurrentPosition(allowInterop((pos) => 성곡(pos)));
}`

loading_screenμ—μ„œ ! μ–΄λ–»κ²Œ μž‘λ™ν•˜λŠ”μ§€ μ΄ν•΄ν•˜μ…¨λ‚˜μš”?

도착할 μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€. 방금 Dart Analysis(Android Studio)κ°€ Function Function(GeoLocationPosition pos)을 μƒμ„±ν•˜λ„λ‘ ν–ˆμŠ΅λ‹ˆλ‹€. get success => null; λ‚΄κ°€ 무엇을 ν•  수 μžˆλŠ”μ§€ μ•Œμ•„λ³΄κ² μŠ΅λ‹ˆλ‹€. ν•˜μ§€λ§Œ μ•„λ‹ˆμš”, 무슨 일이 μΌμ–΄λ‚˜κ³  μžˆλŠ”μ§€ μ „ν˜€ μ΄ν•΄ν•˜μ§€ λͺ»ν•©λ‹ˆλ‹€. μ›Ήμ—μ„œ μœ„μΉ˜ 정보λ₯Ό μ–»λŠ” 이 λ¬Έμ œλŠ” μ €μ—κ²Œ 정말 μ–΄λ €μš΄ λ„μ „μ΄μ—ˆμŠ΅λ‹ˆλ‹€. Flutter Bootcampμ—μ„œ μ΅œμ†Œν•œμ˜ κ²ƒλ§Œ 배운 것 같은 λŠλ‚Œμ΄ λ“€ λ•Œκ°€ μžˆμŠ΅λ‹ˆλ‹€.

κ·Έλž˜μ„œ λ‚΄κ°€ μ„±κ³΅μœΌλ‘œ μ‹œμž‘ν•˜λŠ” 쀄을 μΆ”κ°€ν•˜λ©΄ 음, 그것은 μ™„μ „νžˆ μ‹œν–‰μ°©μ˜€μž…λ‹ˆλ‹€. 어디에 λ„£μ–΄μ•Ό 할지 λͺ¨λ₯΄κ² μŠ΅λ‹ˆλ‹€.

진행 μ€‘μž…λ‹ˆλ‹€. λ§ˆμΉ¨λ‚΄ κΆŒν•œ 창을 λ„μš°λŠ” μ½”λ“œλ₯Ό μ–»μ—ˆμŠ΅λ‹ˆλ‹€. 그리고 μ½˜μ†”μ— λ©”μ‹œμ§€λ₯Ό μΈμ‡„ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€. 도움과 격렀에 κ°μ‚¬λ“œλ¦½λ‹ˆλ‹€. λ‚˜λŠ” 그것이 λ§ˆμΉ¨λ‚΄ μž‘λ™ν•˜κΈ° μ‹œμž‘ν–ˆλ‹€κ³  μƒκ°ν•˜κ³ , 일단 μž‘λ™ν•˜λ©΄ μ΄ν•΄ν•˜λ €κ³  λ…Έλ ₯ν•  κ²ƒμž…λ‹ˆλ‹€. 이 μ§€μ˜€λ‘œμΌ€μ΄ν„° ν”ŒλŸ¬κ·ΈμΈμ΄ ν”ŒλŸ¬ν„° μ›Ήμš©μœΌλ‘œ μ—…λ°μ΄νŠΈλ˜κΈ°λ₯Ό λ°”λžλ‹ˆλ‹€. κ·Έλ™μ•ˆ μ‹œκ°„ λ‚΄μ£Όμ…”μ„œ λ‹€μ‹œ ν•œ 번 κ°μ‚¬λ“œλ¦½λ‹ˆλ‹€. @lionelquirynen

μ’‹μ•„ μ™„λ²½ν•΄! λ„ˆλ¬΄ ν˜Όλž€μŠ€λŸ¬μ›Œν•˜μ§€ μ•ŠκΈ°λ₯Ό λ°”λžλ‹ˆλ‹€. μ•ˆλ‚΄κ°€ ν•„μš”ν•˜λ©΄ μ•Œλ €μ£Όμ„Έμš”!

λ‹€μŒμ€ μ›Ήμ—μ„œ μž‘λ™ν•˜λŠ” κ΅¬ν˜„μž…λ‹ˆλ‹€.
https://github.com/AseemWangoo/experiments_with_web
https://fir-signin-4477d.firebaseapp.com/#/location (μ—… 쀑)
ν”ŒλŸ¬κ·ΈμΈμœΌλ‘œ λ˜λŠ” κ·ΈλŒ€λ‘œ 톡합할 수 μžˆμŠ΅λ‹ˆλ‹€. κ·ΈλŒ€λ‘œλΌλ©΄ kIsWeb 을 μ‚¬μš©ν•˜μ„Έμš”.

ν”ŒλŸ¬ν„° μ›Ήμ—μ„œ μ‚¬μš©μž μœ„μΉ˜λ₯Ό μ–»κ³  μ‹Άμ§€λ§Œ Mozilla GeoLocation이 μž‘λ™ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€ !!! λˆ„κ΅°κ°€ μ €λ₯Ό λ„μšΈ 수 μžˆμŠ΅λ‹ˆκΉŒ?
이것은 StackOverFlow에 λŒ€ν•œ 제 μ§ˆλ¬Έμž…λ‹ˆλ‹€. https://stackoverflow.com/questions/64411270/flutter-web-get-location-on-web-by-location-plugin

이 νŒ¨ν‚€μ§€μ˜ μ›Ή 지원에 λŒ€ν•œ μ†Œμ‹μ΄λ‚˜ μ†Œμ‹μ΄ μžˆμŠ΅λ‹ˆκΉŒ?!

@mvanbeusekom

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰