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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:20:20+00:00 2026-06-13T21:20:20+00:00

I am using maps and backbone.js together. Map JS library used is Leaflet, but

  • 0

I am using maps and backbone.js together. Map JS library used is Leaflet, but Google maps API will apply here as well.

Problem: Backbone.js allows us to seperate the presentation (Views) from the data (Models, Collections). When using Google Maps JS API or Leaflets, we do not seem to have control over the rendering of the markers, thus unable to have a Backbone View for each marker. Is this true?

When using Maps together with backbone.js, I start to get nested views and event handlers in the callback functions.

JS (Leaflet, similar to Google Maps API)

// Handle a dragging on the map
map.on('dragend', function() {
    App.markersList.fetch(
        data: someData,
        processData: true
        function() {
            App.markersListView.render();
    };)
});

// Handle a click on a Marker
map.on('popupopen', function() {
    // Activate bootstrap tabs
    $('#tabs').tab();

    // Submit click handler
    $('#submit-button').click(function() {
        $.post('/api/submit-something',
            {data: data},
            function() {
                // Remove some divs
                $('#some-divs').fadeOut();
            })
    })

    // Activate slideshow
    Galleria.loadTheme('/js/vendor/galleria.miniml.min.js');
    Galleria.configure({
        height: 320
    });
    Galleria.run('#galleria');

    // Validation
    $('.email-link form').validate({
        rules: { ... }
    });


});

Well you get the idea… I need to do these outside of Backbone’s MVC structure. I could be missing out on the correct way to integrate both together. Any ideas? Thanks!!

  • 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-13T21:20:22+00:00Added an answer on June 13, 2026 at 9:20 pm

    I guess with view for the marker you mean the content of a popup to that marker? It is possible to bind a view as the popup content of a feature. At least in Leaflet that is.

    The key is, that Leaflet Popups allow to use a provided DOM element as its content. To have appropriate knowledge of the model behind a marker you may specify the marker as a property of the model. This allows you to get the associated marker of the model. The other way around can be achieved via an event binding to the marker whose signature comprises the model.

    This is a simplified snippet of my map view how to to set it up after fetching the collection:

    _.each(collection.models, function (model) {
        var attr = model.attributes,
            marker = new L.Marker(new L.LatLng(attr.lat, attr.lon));
    
            marker.on('click', function () {
                App.vent.trigger("model:select", model);
            });
    
            model.marker = marker;
            map.addLayer(marker);
    });
    

    Here, for each model in the collection a marker is drawn and then the marker becomes a property of the model. Also, each marker is bound with an click event that triggers the custom “model:select” event on an application-wide event aggregator. From here on you can use that event to set up the popup view by catching the event like:

    common.vent.on('model:select', function (model) {
        this.select(model);
        this.initPopup(model);
    }, this);
    

    InitPopup may look like this:

    initPopup = function (model) {
        var marker = model.marker,
            view = new PopupView({model: model});
    
        marker.bindPopup(view.render().el).openPopup();
    };
    

    The PopupView is a Backbone view (Well, Marionette in my case.) complete with template and event handling and so on.

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

Sidebar

Related Questions

I am using Google Maps V3 API to display my map. Problem: How can
I'm using Google Maps Javascript API V3 Places Library in order to add Places
I am using Google Maps API V2 (I know, but i am editing a
I'm using Google Maps' API and added a few markers in a map. Each
I am using Google Maps API to display a map on a certain page.
Im using Google Maps Javascript API V3, and recently the icons on my map
Using Maps API v3. As per Google documentation, if the map container is resized
I'm using Google Maps API to display a map and some markers on it.
I'm using Google Maps API v2 and Geoxml to produce a map which is
I am using Google Maps API 3. I have a map and a button.

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.