0

I'm using a static google map, but really this problem could apply to any maps project. I want to divide a map into multiple quadrants (of say 50x50 pixels) and label the columns as A, B, C.... and the rows as 1, 2, 3...

Next I plan to do something like,

1) Find the markers which are the farthest north, east, south, and west 2) Use that info to to define the bounding boxes of each row and column box 3) Classify each marker by its row and column (Example Marker 1 = [A,2])

A few requirements,

  • I don't know the zoom level because I let Google set the zoom level appropriately for me and I would rather not use an algorithm that is dependent on a zoom level. I do however know the locations of all of the markers that are shown on the map.

Here is an example of a map that I would like to classify the markers for, static map example link.

I found these which look like a good start, Resource 1, Resource 2

But I think I'm still in need of some help getting started. Can anyone help write out some pseudo code or post a few more resources? I'm kind of in a rut at the moment.

Thanks! Much appreciated of any help!

Ben Holland
  • 2,309
  • 4
  • 34
  • 50
  • Actually, maybe I'm making this harder than it needs to be. I think more what I should be doing is, given my center point and all the markers determine the zoom level (or span size), then using that determine the ratio of pixels to degrees. Then using that compute the corresponding pixel location for each lat,lng pair in my collection and classify that by checking to see which x,y pixel pair that corresponds to the lat,lng pair is in which quadrant. – Ben Holland Dec 27 '10 at 20:31
  • What will be the use of this?Cause maybe i can point you to another direction – Argiropoulos Stavros Dec 28 '10 at 08:56
  • Sorry I didn't see your post here. My use at the time was to create an atlas style map using google static maps. Google maps allows you to label markers A-Z or to use your own custom marker, but really I just wanted to denote which cluster of markers to refer to. I'm curious what resource you had in mind even though I was able to figure out what I needed for my purpose already. – Ben Holland Jan 19 '11 at 01:26

1 Answers1

0

Ok two days into this I finally got it. Thought I would share my thoughts with people who stumble upon this later.

Following the PHP code on this site and for translating lat,lng pairs to pixel coordinates, I was able to classify the individual pixel row by the x value and the column by the pixels y value.

To calculate the zoom level, I determine the maxLat, maxLng, minLat, and minLng values defined by the collection of markers. Then I calculated the bounds of the map at a given zoom level. Finally I used a brute force method of checking if the new bounds of the map determined by the zoom level would include the bounds defined by the max,min lat,lng values of the collection of markers. Starting at zoom level 21 (max zoom on google maps) I decrement the zoom level until I find a zoom level that includes all the markers.

It seems, that the zoom level that is calculated in this method matches Google's preset zoom level selected automatically if you do not provide a zoom level for a static map.

In PHP there is a nice library to do all of this here.

Ben Holland
  • 2,309
  • 4
  • 34
  • 50