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 6873493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:04:32+00:00 2026-05-27T04:04:32+00:00

I have a website where people can view some places on a google map,

  • 0

I have a website where people can view some places on a google map, which are stored with a lat/lng coordinate. The storage is mongodb. Now when the user navigates the map, I need to lookup up which places now are in the visible part of the map.

I’m new to mongo, but have looked at the spatial part. My question is now an effective way to do this lookup.

Do I need to make a ensureIndex each time the user navigates the map, and how do I then query all places within the visible boundaries of the map?

  • 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-27T04:04:33+00:00Added an answer on May 27, 2026 at 4:04 am

    According to the mongo docs, you can query within a bounding box like so

    box = [[40.73083, -73.99756], [40.741404,  -73.988135]]
    db.places.find({"loc" : {"$within" : {"$box" : box}}})
    

    The key point here is the use of within to query within a bounding box.

    In order to get the values for your box, just get the bounds of the google map like so

    map.getBounds()
    

    Where map is your google maps object. getBounds will return a LatLngBounds object from which you can build your box to query mongo.

    As for ensureIndex, you should do that once as far as I know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website where people can upload documents, and view them later at
I have a website which is displayed to visitors via a kiosk. People can
i have a website where people can leave comments on some articles. \ what
I have an website where people can place a vote like this: http://mysite.com/vote/25 This
I have a website that lets people view rows in a table (each row
I have a website where people can upload 30+mb of data in a single
I have a website where people can contact each other, and quite often people
Currently, I have a website that people can open up during a certain team's
I have a website where only a couple of people can access it, so
I run a website which shows related articles widget that people can add on

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.