27.10.2014 Views

Google Maps API 3

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 9 ■ DEALING WITH MASSIVE NUMBERS OF MARKERS<br />

Reducing the Number of Markers Being Displayed<br />

One obvious way of to get around this problem is to not display all the markers all the time. Before<br />

getting into how to code actual solutions to this problem, I’ll explain some possible approaches for<br />

reducing the number of markers being shown. Since v3 is still in beta at the time of writing this book,<br />

I’ve had problems finding relevant examples implemented with v3. So, the examples shown here are<br />

implemented using <strong>Google</strong> <strong>Maps</strong> <strong>API</strong> v2. These concepts can, however, just as well be implemented<br />

using v3. Also, since most of these solutions involve server-side coding, which is beyond the scope of<br />

this book, I’m not going to get into how to actually implement them. Let these first examples just serve<br />

as inspiration for how you can approach the too-many-markers problem.<br />

Searching<br />

One way of reducing the number of markers being displayed is to provide a search function. This way,<br />

even if you have thousands of locations, only the ones that match the search criteria are visible. One<br />

example of this is the search function in <strong>Google</strong> <strong>Maps</strong>. If you search for Starbucks, it will only display<br />

the Starbucks available in the visible map (see Figure 9-3).<br />

Figure 9-3. maps.google.com features a search function that searches the visible map and adds markers of<br />

the locations found.<br />

179

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!