homepage Welcome to WebmasterWorld Guest from 54.166.228.100
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
google map class not working in loop
hozyali




msg:4250486
 10:05 pm on Jan 7, 2011 (gmt 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.

 

penders




msg:4250528
 12:27 am on Jan 8, 2011 (gmt 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?

hozyali




msg:4250585
 7:13 am on Jan 8, 2011 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved