Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7050999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:12:41+00:00 2026-05-28T03:12:41+00:00

I am using the Cakephp Google Map V3 Helper. I can get the google

  • 0

I am using the Cakephp Google Map V3 Helper. I can get the google map to show up but the markers do not. Here is my view code:

    <?php 
echo $this->GoogleMapV3->map();
foreach ($allcondos as $condo) {
    $options = array(
    'lat' => $condo['Unit']['lat'],
    'lng' => $condo['Unit']['lon']
    );
    $this->GoogleMapV3->addMarker($options);
}
?>

I know that if I just tell the app to echo out my $condo[‘Unit’][‘lat’] or [‘lon’] it will do so in the foreach loop (so it is pulling my data). What I don’t know how to do is how to write the code for the $options array. I have also tried this:

    foreach ($allcondos as $condo) {
    $lat=$condo['Unit']['lat'];
    $lon=$condo['Unit']['lon'];
    $options = array(
    'lat' => $lat,
    'lng' => $lon
    );
    $this->GoogleMapV3->addMarker($options);
}

How do I write this correctly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:12:42+00:00Added an answer on May 28, 2026 at 3:12 am

    A couple easy steps to get this to work:

    Download

    Download from https://github.com/dereuromark/cakephp-google-map-v3-helper and place the GoogleMapV3Helper.php file in /app/view/helper/GoogleMapV3Helper.php.

    Load Helper

    Either modify your appcontroller so that the top of it reads like the following:

    <?php   
        class AppController extends Contoller{
            public $helpers = array('Html','Javascript','GoogleMapV3');
        }   
    ?>
    

    Or load it in a single controller by adding it to the helpers array as such:

    <?php   
        class DemoController extends AppContoller{
    
            function map() {
                $this->helpers[] = 'GoogleMapV3';
                #   rest of your code       
            }
        }   
    ?
    

    Include Scripts

    Include Jquery in your header. Include the following as well:

    <?php
        echo '<script type="text/javascript" src="'.$this->GoogleMapV3->apiUrl().'"></script>';
    ?>
    

    Create Map Container

    Put this in your view where you want your map to appear. Feel free to modify the properties of the div.

    <?php echo $this->GoogleMapV3->map(array('div'=>array('id'=>'my_map', 'height'=>'400', 'width'=>'100%'))); ?>
    

    Note: you can change the default position of the map by including more options than just ‘div’:

    <?php echo $this->GoogleMapV3->map(array('map'=>array(
                'defaultLat' => 40, # only last fallback, use Configure::write('Google.lat', ...); to define own one
                'defaultLng' => -74, # only last fallback, use Configure::write('Google.lng', ...); to define own one
                'defaultZoom' => 5,
            ),'div'=>array('id'=>'my_map', 'height'=>'400', 'width'=>'100%'))); ?>
    

    Add markers

    Can be in a loop or whatever, but this is done in the view after your container is created.

    <?php  
        $options = array(
        'lat'=>40.770272,
        'lng'=>-73.974037,
            'title' => 'Some title', # optional
            'content' => '<b>HTML</b> Content for the Bubble/InfoWindow' # optional
        );
        $this->GoogleMapV3->addMarker($options);
    ?>
    

    note: only set the ‘icon’ key in the array if you want to use a custom image. Otherwise, they will not show up.

    Include the script for the markers

    <?php echo $this->GoogleMapV3->script() ?>
    

    All done!

    Alternately, you can use finalize() instead of script() if you do not want to echo the javascript right away, but write it to the buffer for later output in your layout:

    <?php $this->GoogleMapV3->finalize(); ?>
    

    See http://www.dereuromark.de/2010/12/21/googlemapsv3-cakephp-helper/ for details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using CakePHP 1.3.6 I'm sure I may have to add code and examples, but
I am currently working on google map api V3 using cakephp with prototype.js. I
I'm using CakePHP to build an application using the MVC Pattern, but my question
I'm using CakePHP but it's a question about the MVC pattern. I have in
Using cakePHP my goal is to combine the index view of two or more
Using CakePHP, I am finding that I'm duplicating some code between controller actions. I
I'm using cakePHP 1.2, and wondering how I can handle a URL that dynamically
I'm using CakepHP and JQuery for my app. In my code, there is a
I've been working with this plugin: http://www.neilcrookes.com/2009/09/27/get-google-analytics-data-in-your-cakephp/ but honestly it's over my head. Under
Using CakePHP's form helper to generate a checkbox is easy enough; to use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.