Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6699733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:43:49+00:00 2026-05-26T06:43:49+00:00

I’m making a script that will hopefully be mainly PHP so it doesn’t require

  • 0

I’m making a script that will hopefully be mainly PHP so it doesn’t require Javascript later on, but right now I’m stuck on a few things.

  1. What is the best way to store GPS locations, and then compare them? I could use to store them in a database (currently using MySQL), and then find people nearby with some code, but I fear this would quite intensive, especially if a lot of values are in the database. This should be executed on the server, I’m currently using PHP right now.

  2. How can I get this data, and then represent it in Google Maps? I’ve currently got my code working when I have already put in the data, but I would like to get this data from a database. Would it be asking too much of the user to place say 100 markers on a single Google Maps view to represent all people around the world? Or should I just stick with people within a certain area? My current code is:

    var people = [ ['Type1', -33.890542, 151.274856],
                   ['Type2', -33.923036, 151.259052],  
                   ['Type2', -34.028249, 151.157507],  
                   ['Type2', -33.80010128657071, 151.28747820854187],  
                   ['Type1', -33.950198, 151.259302]
                 ];
    

    Each ‘type’ displays a different image, so I need to pull the type, lat and long from a database and put them into this Javascript Array.

I know there’s a few questions thrown in there, I’m new to this side of javascript and Maps 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:43:50+00:00Added an answer on May 26, 2026 at 6:43 am

    1. Your first question

    I had to solve something like this last week and I did it like this.
    Let’s say I have a list of some offices in MySQL database with their GPS coordinates (gps_lat, gps_lon) and I want to sort them by their distance to my current location ($latitude, $longtitude) in km.

    // MySQL query in PHP
    // btw, I'm storing GPS coordinates in decimal format like 51.123234
    $varA = "(POW(SIN((gps_lat - $latitude) / 2 * 0.017453293), 2) + COS($latitude * 0.017453293)
            * COS(gps_lat * 0.017453293) * POW(SIN((gps_lon - $longtitude) / 2 * 0.017453293), 2))";
        
    $query = "SELECT *, (6378.140 * 2 * ATAN2(SQRT($varA), SQRT(1-$varA))) AS distanceInKm ";
    $query += 'FROM Office ORDER BY distanceInKm'); 
    
    $mysqli->query($query);
    // ...
    
    // the magic constant 0.017453293 is PI / 180 (just check the link below).
    

    Maybe check this link Deriving the Haversine Formula, it helped me a lot. I know this looks weird in SQL. The $varA is just one part of the formula that repeats twice. Original formula in the link above looks like this:

    dlon = lon2 - lon1
    dlat = lat2 - lat1
    a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
    c = 2 * atan2(sqrt(a), sqrt(1-a)) 
    d = R * c
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.