2

I have a map where i have created pushPin for all the places i have checked in on facebook. I want to zoom in on the area where i have the most checkinplaces (pushPins).

I could have a static zoom level and calculate some kind of median value but if i check in 20 times in Paris and 20 times in Los Angeles I'd end up somewhere in the middle of the Atlantic Ocean (or the North Pacific or something).

I have an array with all the locations (longitudes and latitudes) to play with.

Johan B
  • 1,976
  • 1
  • 21
  • 40

1 Answers1

1

You can create a bounding box that covers the extent of the pushpins in your array using the LocationRect.fromLocations() method (http://msdn.microsoft.com/en-us/library/gg427621.aspx).

Then, simply centre the map on this view by passing the LocationRect to the "bounds" property of the map.setView method. (http://msdn.microsoft.com/en-us/library/gg427628.aspx)

Alastair Aitchison
  • 3,532
  • 1
  • 16
  • 15
  • Interresting idea but i think it has kind of a similar problem as mine. I live in Stockholm and have checked in numerous time here. If I'm on vacation check in once in Australia all of a sudden I'm zoomed out enough to cover 70% of earth when really all the interresting stuff is (as we all know) happening in Stockholm. – Johan B Aug 19 '11 at 07:59
  • So, in the example in your question (20 Check-ins in Paris, 20 Check-ins in Los Angeles), where do you actually want the map to be centred? Arbitrarily on one city or the other? – Alastair Aitchison Aug 19 '11 at 16:59
  • Yeah, the area with most checkins. – Johan B Aug 22 '11 at 15:37