“React Native”使用本地地图选择位置
我需要用户选择事件的位置。
现在已经有效的是打开本机地图(至少在 Android 上) - 我可以通过 { Linking } from "react-native";
geo:24.669026,24.699024?z 打开本机地图=6
但是我找不到如何让原生地图提示用户设置某个位置并经过某种确认?
我想象了类似 return_url
的东西,带有某种指向我的应用程序的反向链接。
或者这只能通过嵌入地图和使用 Google Maps API 来实现?
(我试图避免计费,因为我想做的就是帮助用户找到坐标并将它们放回应用程序,除了发送用户将它们显示在本机地图上之外,应用程序不使用坐标执行任何操作)
I need user to select location of an event.
Now what already works is opening the native maps (at least on android) - I can open the native maps through { Linking } from "react-native";
geo:24.669026,24.699024?z=6
However what I can't find how to make native maps prompt user to set some location and after some kind of confirmation?
I imagined something like return_url
with some sort of backlink to my application.
Or is this ONLY possible through embeding maps and using Google Maps API?
(I am trying to avoid billing, since all I want to do is to help user to find the coordinates and put them back to application, the application doesn't use the coordinates to do anything besides sending user to display them on they native maps)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因此,如果我理解正确,您希望在地图上显示用户的当前位置,而不向任何第三方付费,如果是这种情况,您需要执行以下操作。
1.获取用户经纬度。
您可以按照下面的文章获取用户经纬度。
2.使用一些标记在地图上显示这些纬度和经度。
因此,在这一步中,我们将使用
react-native-maps
和OpenStreetMap
。注意:请勿更改
UrlTile
中的urlTemplate
这是来自
react-native-maps
的自定义地图图块的参考>https://github.com/react-native-maps/react-native-maps#tile-overlay-using-tile-server
so if I understood you correctly you want to show the user's current location on the map without paying to any third party, if that's the case you need to do the followings.
1. Get user latitude and longitude.
You can follow the below article for getting user latitude and longitude.
2. Show those latitudes and longitudes on the map using some marker.
So in this step, we will be using
react-native-maps
andOpenStreetMap
.Note: Do not change
urlTemplate
in theUrlTile
Here is the reference for custom map tile from
react-native-maps
https://github.com/react-native-maps/react-native-maps#tile-overlay-using-tile-server
目前您无法使用
react-native
做到这一点,您必须添加自己的地图。您可以使用 react-native-mapsYou currently can't do that with
react-native
, you have to add your own map. You can use react-native-maps