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

  • SEARCH
  • Home
  • 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 8728543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:39:57+00:00 2026-06-13T08:39:57+00:00

I have the following setup: class App.Views.Maps extends Backbone.View el: ‘#map’ events: initialize: ->

  • 0

I have the following setup:

class App.Views.Maps extends Backbone.View

el: '#map'

  events:


  initialize: ->
    @searchModel = new App.Models.Search()
    @view = new App.Views.MapBox(map: this)

    @render()

  render: ->
    @loadMap()
    $("[rel=tooltip]").tooltip()

 loadMap: =>
    osmMapType = new google.maps.ImageMapType(
      getTileUrl: (coord, zoom) ->
        "http://tile.openstreetmap.org/#{zoom}/#{coord.x}/#{coord.y}.png"
      tileSize: new google.maps.Size(256, 256)
      isPng: true
      alt: "OpenStreetMap layer"
      name: "OSM"
      maxZoom: 19
    )

cloudMadeMapType = new google.maps.ImageMapType(
  getTileUrl: (coord, zoom) ->
    "http://b.tile.cloudmade.com/111/54912/256/#{zoom}/#{coord.x}/#{coord.y}.png"
  tileSize: new google.maps.Size(256, 256)
  isPng: true
  alt: "CloudMade layer"
  name: "CMade"
  maxZoom: 13
)

lat = 51.503
lng = -0.113
latlng = new google.maps.LatLng(lat, lng)
options =
  zoom: 10
  center: latlng
  mapTypeId: 'OSM'
@gMap = new google.maps.Map(document.getElementById("map"), options)
@gMap.mapTypes.set('OSM', osmMapType)
@gMap.mapTypes.set('CloudMade', cloudMadeMapType)
@gMap.setMapTypeId('CloudMade')

allowedBounds = new google.maps.LatLngBounds(
  new google.maps.LatLng(51.278, -0.536)  
  new google.maps.LatLng(51.701, 0.309)
)

lastValidCenter = new google.maps.LatLng(51.503,-0.113)

google.maps.event.addListener @gMap, "dragend", =>
  if allowedBounds.contains(@gMap.getCenter())
    lastValidCenter = @gMap.getCenter()
    return
  $('#myModal').modal(backdrop: true)
  $('#myModal').on('hide', => 
    origin = new google.maps.LatLng(51.438264485659836,-0.05715396179630261)
    @gMap.setCenter(origin)
    center = google.maps.LatLng(51.503,-0.113)
    @gMap.panTo(origin)

    )
@initLabel()


initLabel: =>
    #rendered = view.render().el
    #console.log rendered
    @initLabel = new InfoBubble(
      position: new google.maps.LatLng(51.44115356738888, 0.14849636779354114)
      maxWidth: 240
      maxHeight: 210
      padding: 0
      content: '<div class="tooltip_header"></div>'
      tabPadding: 15
      backgroundColor: 'black'
      borderRadius: 0
      arrowSize: 10
      borderWidth: 0
      borderColor: '#AB2424'
      disableAutoPan: true
      hideCloseButton: false
      arrowPosition: 0.5
      backgroundClassName: 'phoney'
      tabClassName: 'tabClass'
      activeTabClassName: 'activeTabClass'
      arrowStyle: 2
    )
    @initLabel.open(@gMap)

This loads a map and then loads an InfoBubble ontop of the map. It loads it with the content <div class="tooltip_header"></div>
After this has loaded, if I append the loadMap and add

view = new App.Views.MapBox()
view.render().el

which attempts to load the view:

class App.Views.MapBox extends Backbone.View

    el: '.tooltip_header'

    events:
      'click .testdrive' : 'loadTestDrive'
      'click .test' : 'loadTestDrive'

    template: JST["app/backbone/templates/mapbox"]

    initialize: ->

      @render()

    render: ->
      $(@el).html(@template())
      this

    loadTestDrive: ->
      console.log @options.map
      console.log "yessss"
      @options.map.loadTestDrive()

Nothing happens… however if I go into console and do:

view = new App.Views.MapBox({map: this})

The content is rendered inside the Infobubble ontop of the map.

I think its because the load of InfoBubble is Asynchronous and I am calling the div to be rendered before it exists. But I have tried delay loading and it still happens.

What is the best way to get this view to render after the infobubble is loaded and the div is therefore available. This is why it works in console. but not on load.

  • 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-13T08:39:58+00:00Added an answer on June 13, 2026 at 8:39 am

    Just use google maps events to listen to when the map is fully loaded like this

        google.maps.event.addListener(map, 'tilesloaded', _.bind(function() {
            this.render();
            google.maps.event.clearListeners(map, 'tilesloaded');
        },this));
    

    With this you are 100% sure the map is rendered and the google.maps globals are avaliable and initialized.

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

Sidebar

Related Questions

I am pretty new to backbone.js. I have the following setup Scripts |--App |
i have the following models setup class Player(models.Model): #slug = models.slugField(max_length=200) Player_Name = models.CharField(max_length=100)
If I have the following has_one setup: class Account has_one :user How can I
I have following models setup in my Django application class School(models.Model): name = models.TextField()
I have the following setup. Class, say, Car that has a CarPart (belongsTo=[car:Car]). When
I have the following setup in app.config: <hibernate-configuration xmlns=urn:nhibernate-configuration-2.2 > <session-factory name=Nh.Data> <property name=connection.provider>
I have the following setup: ASP.net 3.5 Web Site Project C# Class Library with
I have the following models set up: class Contact < ActiveRecord::Base belongs_to :band belongs_to
I have the following function set up to sequentially fade in divs (with class
I have set up the following: Database class ($db) Pagination class ($paginator) I am

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.