Jump to content

Multiple maps showing the same area within repeater


melissa_boyle
 Share

Recommended Posts

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

  • 2 weeks later...

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

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

  • 4 weeks later...

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

<?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.

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...