Welcome to WebmasterWorld Guest from 54.163.65.181

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)

Junior Member

5+ Year Member

joined:Aug 7, 2008
posts: 93
votes: 0


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');
$map->setAPIKey('MYAPIKEY');
$ven_name = 'PLACENAME';
$mapaddress = 'MYADDRESS';
$map->addMarkerByAddress($ven_name.' '.$mapaddress,'<b>'.$ven_name.'</b>'.$mapaddress);
$map->printHeaderJS();
$map->printMapJS();
$map->printMap();



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)

Senior Member

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

joined:July 3, 2006
posts: 3123
votes: 0


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)

Junior Member

5+ Year Member

joined:Aug 7, 2008
posts: 93
votes: 0


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.