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 9253059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:07:08+00:00 2026-06-18T11:07:08+00:00

Hi guys i am trying to create a Google map view with backbone.js but

  • 0

Hi guys i am trying to create a Google map view with backbone.js but i dont really understand what i need to do in order to achieve it.

This is what i have so far (and i am not sure if that is correct as well). and i really dont understand what needs to happen in the render function for this kind of view.

  MYAPP.Widgets.Map = Backbone.View.extend({
    template : template('grid-12'),
    initialize: function(){
    },
    activate: function(){
        var mapOptions = {
                  zoom: 8,
                  center: new google.maps.LatLng(-34.397, 150.644),
                  mapTypeId: google.maps.MapTypeId.ROADMAP
                };
    this.map = new google.maps.Map(document.getElementById('googleMapBox'),mapOptions);
    },
    render: function(){
        this.$el.html(this.template(this));
        this.activate();
        return this;
    },
});

Thanks

EDITED:
I have looked in the threads that tkone has mentioned.
i don’t see the answer there and i don’t really understand why he is refusing to give any real help in the matter. It might be from my lack of knowledge in JS or backbone (which really doesn’t matter). the same issue with tkone was mentioned in the other posts where another user was not able to understand how to make this work.

i have managed to get this far but i am getting this error

   Uncaught TypeError: Cannot read property 'offsetWidth' of null main.js:28
                                                               ih main.js:28
                                                               Lh main.js:34
MYAPP.Widgets.Map.Backbone.View.extend.activate MTAPP.widgets.js:23
MYAPP.Widgets.Map.Backbone.View.extend.render MYAPP.widgets.js:38

(anonymous function)

i hope theres anyone else who might want to contribute in solving this matter.

UPDATE So following the comments the getElement function did return null, so i switched it up with a jquery selector that returned an element

BUT!, i did get a different error: Uncaught TypeError: Cannot set property ‘position’ of undefined

Following this thread:
Uncaught TypeError: Cannot set property 'position' of undefined

i see that you cannot send a jquery element to the Map object. so now i am stuck with how to extract the actual DOM element from the jquery one.

following this thread:
How to get a DOM Element from a JQuery Selector

i was finally able solve it.

thank you.

  • 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-06-18T11:07:09+00:00Added an answer on June 18, 2026 at 11:07 am

    The way i got to the solution is thanks to the comments by @dbaseman and other thread i have found, all listed in the actual question. I will just post the complete solution:

       MYAPP.Widgets.Map = Backbone.View.extend({
        template : template('grid-12'),
        initialize: function(){
        },
        activate: function(){
            var mapOptions = {
                      zoom: 8,
                      center: new google.maps.LatLng(-34.397, 150.644),
                      mapTypeId: google.maps.MapTypeId.ROADMAP
                    };
            var domElement = this.$('#googleMapBox');
            this.map = new google.maps.Map(domElement.get(0),mapOptions);
        },
        render: function(){
            this.$el.html(this.template(this));
            this.activate();
            return this;
        },
    });
    

    where the Template function is just:

      var template = function (name) {
        var source = $('#' + name + '-template').html();
        return Handlebars.compile(source);
    };
    

    The template itself is:

    <script type="text/x-mustache-template" id="grid-12-template">
    <div class="row-fluid sortable ui-sortable">
                <div class="box span12">
                    <div class="box-header">
                        <h2><i class="icon-th"></i><span class="break"></span>thegrid</h2>
                        <div class="box-icon">
                            <a href="#" class="btn-setting"><i class="icon-wrench"></i></a>
                            <a href="#" class="btn-minimize"><i class="icon-chevron-up"></i></a>
                            <a href="#" class="btn-close"><i class="icon-remove"></i></a>
                        </div>
                    </div>
                    <div id="googleMapBox" class="box-content">
                  </div>
                </div><!--/span-->
            </div>
    </script>
    

    Good luck

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

Sidebar

Related Questions

Hi guys i'm trying to create this (image) css border around a div, but
Hi guys I'm trying to create cookies but with no success. Here is my
I am trying to create a table view header with rounded corners but a
This is probably a very simple problem but I'm trying to create an array
Hi guys I'm trying to create a javascript object like this: data = {
Hi guys i am trying to create one simple make file and execute in
Hey guys - I'm tearing my hair out trying to create a regular expression
hello guys I am trying to extract all the anchor links from aol but
I Am trying to create a buildout recipe for pywhois on google code. The
Hello Guys, I was just trying to create a plugin, and I needed it

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.