tags:

views:

165

answers:

2

I want to divide the Google map display into 200 parts , I have this code

bounds = map.getBounds();
southWest = bounds.getSouthWest();
northEast = bounds.getNorthEast();

tileWidth  = (northEast.lng() - southWest.lng()) / 10; 
tileHeight = (northEast.lat() - southWest.lat()) / 20; 

for (x=0; x < 20 ; x++)
{
for (y=0; y < 10 ; y++)
{
 var x1 = southWest.lat()+ (tileHeight * x);
 var y1 = southWest.lng()+ (tileWidth * y);
 var x2 = x1 + tileHeight;
 var y2 = y1 + tileWidth;

 var tempCell = new GLatLngBounds(new GLatLng(x1, y1), new GLatLng(x2, y2));
}
}

I just cant figure out what is wrong with it... Any Idea ??

A: 

I can't help but notice you use tempCell to hold the result, but what is done after that? do you ever refer to those bounded regions again?

Jonathan Fingland
just use map.addOverlay(new Rectangle(tempCell));
openidsujoy
and want to use again
openidsujoy
A: 

I tried the code you posted - it seems to work just fine. The problem is probably elsewhere in your code. Can you post more details?

It is worthwhile to note, however, that this code will fail in spectacular fashion if the bounds include the international date line. Let us know if this is the problem.

Chris B
Hello Chris,Actually in Google MAP UI every parts(of 200 parts) are not showing of same size , as density of LatLong are not same in every palce in MAP, so at first glance it's seem to me as problem in my code.
openidsujoy
I think I understand - The parts get larger as you move closer to the poles, and you want every part to be the same size on the screen. Is that right? Would it be an option to divide up the map based on the screen pixels? What are you doing with the parts?
Chris B