Baidu MAP range-based search --- Note

Source: Internet
Author: User

Application Scenario Description: Assume that there is a merchant table in the database, which records the basic information and coordinates of Some sellers,

In this case, how can I quickly find qualified merchants in a specified region through location in my app?


The following is the implementation of Java code:

/** Baidu map * obtains the latitude and longitude ranges of the given latitude and longitude distance from the radius ** @ Param lat latitude * @ Param Lon longitude * @ Param raidus unit: M * @ return array minlng, minlat, maxlng, maxlat */public static double [] getaround (double Lon, double Lat, int raidus) {double latitude = Lat; double longpolling = Lon; double Degree = (24901*1609)/360.0; double raidusmile = raidus; double dpmlat = 1/degree; double radiuslat = dpmlat * raidusmile; double minlat = latitude-radiuslat; double maxlat = latitude + radiuslat; double mpdlng = math. ABS (degree * Math. cos (latitude * (PI/180); double dpmlng = 1/mpdlng; double radiuslng = dpmlng * raidusmile; double minlng = longbench-radiuslng; double maxlng = longbench + radiuslng; return New Double [] {minlng, minlat, maxlng, maxlat };}

Based on the obtained coordinate range, you only need to write an SQL statement to quickly find qualified merchants in the specified region.

In this way, it is much faster than storing customer information directly to Baidu cloud and then calling Baidu map API for search.


This article from the "Wandering footsteps" blog, please be sure to keep this source http://now51jq.blog.51cto.com/3474143/1540398

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.