melissa_boyle Posted April 11, 2014 Share Posted April 11, 2014 Hi Guys, I have created a repeater area which outputs multiple maps. All works well bringing the different address etc in but each map displays the same data- only in the browser not within process wire. I assume its an issue with the way I have formatted it but am not sure. Does anyone have any ideas? Thanks, Melissa <?php foreach($page->maps_left as $maps_left) { echo "<div class='location_box {$maps_left->left_or_right}'>"; echo "<h1>{$maps_left->maps_left_title}</h1><p>"; echo "<p>{$maps_left->google_maps_left->address}</p><hr>"; $maps_left= $modules->get('MarkupGoogleMap'); echo "{$maps_left->render($page, 'map')}"; echo "</div>"; } ?> Link to comment Share on other sites More sharing options...
Mats Posted April 11, 2014 Share Posted April 11, 2014 Hi! Try this: $map = $modules->get('MarkupGoogleMap'); foreach ($pages->get("/page-with-maps/")->map_rep as $m) { echo $map->render($m, 'map'); } Link to comment Share on other sites More sharing options...
melissa_boyle Posted April 23, 2014 Author Share Posted April 23, 2014 Hi, Thank you for your response,unfortunately this approach didn't work. I have shown how I have applied it below, it doesn't bring back anything at all for the maps now . <?php foreach($page->maps_left as $maps_left) { echo "<div class='location_box {$maps_left->left_or_right}'>"; echo "<h1>{$maps_left->maps_left_title}</h1><p>"; echo "<p>{$maps_left->google_maps_left->address}</p><hr>"; $maps_left= $modules->get('MarkupGoogleMap'); foreach ($pages->get("/locations/")->maps_left as $m) { echo $maps_left->render($m, 'map'); } echo "</div>"; } ?> Thanks again for your time, Melissa Link to comment Share on other sites More sharing options...
Mats Posted April 23, 2014 Share Posted April 23, 2014 Hi! Include the module only once, before the foreach loop. Right now your including it for every foreach which is not necessary. I'm not sure how you set the repeater up. Is maps_left the repeater field? And maps_left_title a text field inside the repeater? I'm not sure what google_maps_left field does/is ? You could try something like this: <?php $map = $modules->get('MarkupGoogleMap'); //Include the module once. foreach($page->maps_left as $maps_left){ echo "<h1>$maps_left->map_left_title</h1>"; echo "<p>{$maps_left->google_maps_left}</p><hr>" echo $map->render($map_left, 'map'); } ?> Here's a couple of working examples: http://tegelwebb.se/test/ http://alltpaoland.com/testwaypoint/ Link to comment Share on other sites More sharing options...
melissa_boyle Posted May 20, 2014 Author Share Posted May 20, 2014 Hey Mats, I have give that a go but again no map is showing with exception of the main map: I have explained in more detail below: Maps_left is the repeater with google_maps_left being the map marker. I have a main map followed by smaller maps which are in maps_left repeater field. I have included the full code below. <?php echo $page->location_info; ?> <h1> <?php echo $page->mainmap_title; ?> </h1> <p><?php echo $page->map->address; ?></p><hr> <?php $map = $modules->get('MarkupGoogleMap'); echo $map->render($page, 'map'); ?> <div class="location_others"><!-- open location_others --> <?php foreach($page->maps_left as $maps_left){ echo "<div class='location_box {$maps_left->left_or_right}'>"; echo "<h1>$maps_left->map_left_title</h1>"; echo "<p>{$maps_left->google_maps_left}</p><hr>"; echo $map->render($maps_left, 'map'); echo "</div>"; } ?> Thanks for all your help. Melissa Link to comment Share on other sites More sharing options...
Mats Posted May 20, 2014 Share Posted May 20, 2014 Did you check the console if there are any javascript errors? Do you have a width and height for the smaller maps div? Link to comment Share on other sites More sharing options...
melissa_boyle Posted May 20, 2014 Author Share Posted May 20, 2014 No JS errors and the smaller maps do have a set height and width- nightmare Link to comment Share on other sites More sharing options...
Mats Posted May 20, 2014 Share Posted May 20, 2014 <?php foreach($page->maps_left as $maps_left){ echo "<div class='location_box {$maps_left->left_or_right}'>"; echo "<h1>$maps_left->map_left_title</h1>"; echo "<p>{$maps_left->google_maps_left}</p><hr>"; echo $map->render($maps_left, 'google_maps_left'); echo "</div>"; } ?> Try changing map to google_maps_left. 1 Link to comment Share on other sites More sharing options...
melissa_boyle Posted May 20, 2014 Author Share Posted May 20, 2014 Yayyyyy! It worked. Many thanks for your help! Woohoooo! 2 Link to comment Share on other sites More sharing options...
Mats Posted May 20, 2014 Share Posted May 20, 2014 You're welcome! Glad you got it working! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now