简体   繁体   中英

Location based GET and POST API's for java spring boot application

For the app side I want to create a API for posting a product. Also I want to display the product in web site based on the location where the user browsing. What is the proper way to approach this scenario.

My thoughts are (pardon me if am wrong):

  1. Get location (latitude and longitude) from google map and save those data in DB while posting the product, when displaying in web site get location of the device (allow location on device) and display the result from DB according to the coordinates of the device location.

  2. Get the IP address of the posting device and find the location and get district (like nearby district or state) then post the field(district) into DB, when displaying in website get the device IP address and find the location (district or state) and match those data and filter the result from database.

I'd say that the first approach is better, but may be harder to implement. Keep in mind that if somebody is using VPN, you won't get his direct IP address but rather IP address of VPN server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM