27.10.2014 Views

Google Maps API 3

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

The options object is an object literal that you just pass along when creating a new MarkerManager<br />

object. So if you want to set the maxZoom to 15, the borderPadding to 0, and the trackMarkers to true, you<br />

do it like this:<br />

var mgr = new MarkerManager(map, {<br />

'maxZoom': 15,<br />

'borderPadding': 0,<br />

'trackMarkers': true<br />

});<br />

In this example, I changed all the properties, but you don’t have to do that. You can just define those<br />

that you want to change. For example, if I only want to change the trackMarkers property to true, I write<br />

it like this:<br />

var mgr = new MarkerManager(map, {<br />

'trackMarkers': true<br />

});<br />

Further Resources<br />

We’ve been looking at some of the features of MarkerManager library, but there’s even more to it. The<br />

library features a number of methods that you can use to show and hide markers, clear markers, and<br />

other useful things. For a full description of all the methods available, check out the reference<br />

documentation at the file repository at http://google-maps-utility-libraryv3.googlecode.com/svn/tags/markermanager/1.0/docs/reference.html.<br />

Summary<br />

In this chapter, you learned about different ways of dealing with a lot of markers. The best solution is<br />

often to not show all markers at the same time. You can do this by adding filtering, searching or<br />

clustering capabilities. Sometimes even not using markers at all is a solution. If none of these<br />

approaches is a viable solution to the problem, then at least you can resort to using the utility library<br />

MarkerManager, which will increase the overall performance of the map by only adding those<br />

markers that are currently within the viewport.<br />

210

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

Saved successfully!

Ooh no, something went wrong!