Jump to content
melissa_boyle

Multiple maps showing the same area within repeater

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>";
?>

Share this post


Link to post
Share on other sites

Hi!

Try this:

$map = $modules->get('MarkupGoogleMap'); 

foreach ($pages->get("/page-with-maps/")->map_rep as $m) {
  echo $map->render($m, 'map'); 
}

Share this post


Link to post
Share on other sites

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 

Share this post


Link to post
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/

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Did you check the console if there are any javascript errors?

Do you have a width and height for the smaller maps div?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...