Blog » How Do We Do Location Searches For Medical Marijuana?

March 12, 2011 by

The Locate functionality is the centerpiece of – the technology behind it probably does a lot more than you think it does! Outside of the Locate page itself, the technology behind it is used all over the site to show strains, clinics, dispensaries, and grow shops near to your location. If you are one of the lucky dispensaries to be featured while CannaCentral is still in beta – your information is shown across the site thanks to the the same geolocation/spatial technology. Even our search results are incorporation more and more of this functionality to help show content that is relevant to you – and we’re guessing that if you live in Los Angeles, CA there is a good chance you want to see different information than someone living in Bozeman, MT. This is what makes CannaCentral a true Location Based Service, and where other sites fall short.

When CannaCentral was first conceived, it was envisioned to become just another medical marijuana directory site – much like many of our competitors – but with a clean design and a goal of helping the community by offering as many free features as we could. During a (2 hour) long commute to discuss how to to go about it all, the real concept behind what is now CannaCentral was born – a site that is truly location based, showing you only the content that is most relevant to you. We wanted to make it easy to find specific information, while still making it easy to browse through our content. It seemed like a great idea, and also a lot of work, but we decided to get started with it anyway. At the end of the first day we had the first version of our technology written – and it took 12 seconds every time we ran it. For those that are curious, it was based on a Haversine formula to calculate the distance between two points, taking account of the curvature of the Earth.

In this age of computing, waiting 12 seconds for a web page to load is not acceptable and certainly not more than that, especially since it might run more than once per page load. After spending more time focused on speed – the results we were getting were accurate – we were able to get the query optimized and running in 4 seconds, and with some additional database work, results were coming in around 2 seconds. This was 6x faster, but still noticeably slow for the user, so we used some advanced preloading and caching algorithms while we spent more time looking at our technology – fake it ’til you make it. We were still using the Haversine-based search, but with improved indexing and query structure – more joins and fewer subqueries.

After another visit to the drawing board, some additional SQL optimizations, more database work, and a move to a faster server, we can now search for strains, clinics, dispensaries, grow shops and more, all close to you, and typically all in less than 200 milliseconds. We are now using a complex set application and database programming as well as GIS spatial datatypes and indexes for the fastest performance available and accuracy ensured using the trusty Haversine formula that started it all.

There have also been drastic improvements to the user interface of the Locate page. Both in terms of data as well as functionality and performance, we feel like our interface is as good as they get for location based sites. A quick run down of some of the latest improvements:

  • As part of our partnership with, you can now display strain attributes in your results. When searching for strains you can also sort by these attributes
  • All search results are added to the map using colored markers and letters, now including strains at their nearest location.
  • New results are automatically loaded as you scroll down the page up to three times. For results beyond these, just click the link to load in additional items.
  • If you are using a modern browser, you can lookup your location by clicking the link above the location input – this is most accurate when using WiFi

We are happy with the direction that is headed, and have a bunch of cool features still in the works, but we would also love to hear what you have to say. Drop us a note on the Contact Us page or follow us on Facebook, Twitter, or your favorite RSS reader.

2 Responses

  1. Rhory Gould via Facebook on

    Always Good…….

    Report this comment

  2. I think this site is unbelievable. I just think i need a book for dummies.tring to go over the pros and cons of using medical marijuana.I am stuck on finding a doctor who will write a prescription for me who is located in my city.I am on the boarder or Calif and Nevada. I understand if my id is in Nv then i have to have a prescription from that state and where to look for dispensaries.This is why i feel like a need a book for dummies.

    Report this comment

Leave a Reply

You must be logged in to post a comment.