Javascript-Baidu LBS locates the user's latitude and longitude, and compares the merchant's latitude and longitude in the database to obtain the distance from the merchant

Source: Internet
Author: User
The solution has been solved by using geohash. The idea is to use geohash to calculate the user's latitude and longitude, and calculate the latitude and longitude of the user's merchants using geohash as average. Then, we can make a comparison, you can paste two links to the geohash class Link Description operation method Link Description ---------- split line ------...

The solution has been solved by using geohash. The idea is to use geohash to calculate the user's latitude and longitude, and calculate the latitude and longitude in the merchant's own business using geohash. Then, we can compare it.
Paste two links

  1. Geohash Link Description

  2. Operation Method Link Description

---------- Split line ------------------

We are currently working on a page, similar to the features of sellers near the Meituan page

Requirements: Displays information about nearby merchants and shows the distance (for example, 1000 meters)
CurrentlyBaidu LBS Open Platform: Browser PositioningTo user dimension

The database also savesBusiness longitude and latitudeI heard that Baidu appstore also has a range-based api, but I don't know how to integrate it into a piece.
How should we develop this?

Reply content:

The solution has been solved by using geohash. The idea is to use geohash to calculate the user's latitude and longitude, and calculate the latitude and longitude in the merchant's own business using geohash. Then, we can compare it.
Paste two links

  1. Geohash Link Description

  2. Operation Method Link Description

---------- Split line ------------------

We are currently working on a page, similar to the features of sellers near the Meituan page

Requirements: Displays information about nearby merchants and shows the distance (for example, 1000 meters)
CurrentlyBaidu LBS Open Platform: Browser PositioningTo user dimension

The database also savesBusiness longitude and latitudeI heard that Baidu appstore also has a range-based api, but I don't know how to integrate it into a piece.
How should we develop this?

If you have a merchant's latitude and longitude, baidu should have an api for calculating the distance. If you do it yourself,
1. Use mongodb
2. Use the geohash algorithm to save the longitude and latitude as hash.

The question is rough. I can only tell you about my method in general, and I have done something similar.
1. Store the merchant's location information in segments according to the city,
2. the browser obtains the user location and uses Baidu's map js api.
3. Calculate a rectangle centered on the user location.
4. Match the longitude and latitude values and distance values in the database to obtain appropriate merchant information.
5. displayed

MongoDB supports location-based Query

Baidu:
redis geoOrmongodb geoOrpostgresql geoOrmysql geo

I didn't even mention it,
Use Baidu map API →IOV APIs: Measure the linear distance between multiple points.

IOV APIs

To obtain the line distance: RequiredDirection API
Http://developer.baidu.com/map/index.php? Title = webapi/direction-api

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.