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

  • SEARCH
  • Home
  • 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 9103567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:39:43+00:00 2026-06-17T01:39:43+00:00

I’m attempting to make a geospatial query in mongodb using the $within operator. I

  • 0

I’m attempting to make a geospatial query in mongodb using the $within operator. I have a collection entry that has a location field which holds:

location: {
  bounds: {
    south_west: { lat: XX.XXXXXX, lng: XX.XXXXX },
    north_east: { lat: XX.XXXXXX, lng: XX.XXXXX }
  },
  center: {
    lat: XX.XXXXXX,
    lng: XX.XXXXXX
  }
}

For my query, I’d like to get all places with a location.center that falls within the bounds of the google.maps object. I have something like this:

query = {}

var southWest = map.getBounds().getSouthWest();
southWest = [southWest.lat(), southWest.lng()];

var northEast = map.getBounds().getNorthEast();
northEast = [northEast.lat(), northEast.lng()];

query["location.center"] = { $within: { $box: [southWest, northEast] } }

But I consistently get

Exception from Meteor.flush: Error: Unrecognized key in selector: $within
at Error (<anonymous>)
at Function.LocalCollection._exprForConstraint (http://localhost:3000/packages/minimongo/selector.js?2373a18a9a4640513e41d7850f17f62f76b7c589:559:11)
at Function.LocalCollection._exprForOperatorTest (http://localhost:3000/packages/minimongo/selector.js?2373a18a9a4640513e41d7850f17f62f76b7c589:468:36)
at Function.LocalCollection._exprForKeypathPredicate (http://localhost:3000/packages/minimongo/selector.js?2373a18a9a4640513e41d7850f17f62f76b7c589:387:34)
at Function.LocalCollection._exprForSelector (http://localhost:3000/packages/minimongo/selector.js?2373a18a9a4640513e41d7850f17f62f76b7c589:307:36)
at Function.LocalCollection._compileSelector (http://localhost:3000/packages/minimongo/selector.js?2373a18a9a4640513e41d7850f17f62f76b7c589:284:24)
at new LocalCollection.Cursor (http://localhost:3000/packages/minimongo/minimongo.js?7f5131f0f3d86c8269a6e6db0e2467e28eff6422:71:39)
at LocalCollection.find (http://localhost:3000/packages/minimongo/minimongo.js?7f5131f0f3d86c8269a6e6db0e2467e28eff6422:57:10)
at _.extend.find (http://localhost:3000/packages/mongo-livedata/collection.js?3ef9efcb8726ddf54f58384b2d8f226aaec8fd53:155:34)
at Template.feed.feed_items (http://localhost:3000/client/modules/js/feed.js?5ed30ddbd861944b636dbe03c13cc80421258a5b:129:17) 

And I’m unsure how to proceed. With a simple JSON.stringify(query) I’ve noticed that the query is coming out like

{"location.center":{"$within":{"$box":[[39.93623526127148,-75.63687337060549],[39.984129247435064,-75.57438862939455]]}}}

Is there anyway I can prevent the quotes from being wrapped around the $within and $box selectors? I believe that’s where my exception is being thrown from.

  • 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-06-17T01:39:44+00:00Added an answer on June 17, 2026 at 1:39 am

    The quotes aren’t the problem, that’s just valid JSON. The problem is that minimongo doesn’t implement $within yet. Matt Debergalis commented on Minimongo’s incomplete state (23 oct 2012):

    The recent traffic on meteor-talk reminds me that minimongo comes with
    a healthy wish list of improvements and extensions.

    […]

    • $near, $within, and $maxDistance.

    You may have better luck executing this in the server where you have “real” mongodb access, but I’m not sure how that works if the client store doesn’t have the same functionality.

    Minimongo’s source code is available. Perhaps you should try your hand at implementing this selector yourself and sending a pull request? 🙂

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I have an array which has BIG numbers and small numbers in it. I
I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.