Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

google map class not working in loop



10:05 pm on Jan 7, 2011 (gmt 0)

5+ Year Member

Hello friends,

I am having a hard time handling this.

I have a google api class downloaded from somewhere and it works fine on a page which has to call the map only once. it shows properly.

the problem occurs when I have to call the map in a loop. I need this map to appear in a loop where it has to print it several times on the page. in that case, it just loads it once on first record, but doesn't load it in the rest of the records.

I call the map class like this which works for single placement

$map = new GoogleMapAPI('map');
$ven_name = 'PLACENAME';
$mapaddress = 'MYADDRESS';
$map->addMarkerByAddress($ven_name.' '.$mapaddress,'<b>'.$ven_name.'</b>'.$mapaddress);

so when I call the whole code above in a WHILE or FOR loop, it doesn't load except the first record.

the class code is really the base code which I never modify or touch. but if the class is needed for better understanding, let me know, I can post it too.

Thanks a lot for helping out.


12:27 am on Jan 8, 2011 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

It might help if you post your loop code as well, showing the values that change. Do the print...() methods themselves echo content to the page, or are you doing this somewhere else?


7:13 am on Jan 8, 2011 (gmt 0)

5+ Year Member

yes, $map->printMap() actually shows the map on the page.

the loop, it simply works like a while loop.

and the whole code I pasted above goes in the loop each time.

hope it helps.

Featured Threads

Hot Threads This Week

Hot Threads This Month