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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:13:56+00:00 2026-06-15T00:13:56+00:00

I’ve a layout template with a left sidebar where I show information of Location

  • 0

I’ve a layout template with a left sidebar where I show information of Location passed entities as an array.

Also in this template, I show a object Map with all of this locations.

I want to do click on a Location of my sidebar and then on the same template show another object Map replacing the previous with information of this Location. Keeping the sidebar with the information and not doing new queries on the database.

How to achieve this?

Ajax? Conditional layout?

I read this article but I don’t understand how to solved my problem: http://twig.sensiolabs.org/doc/recipes.html#overriding-a-template-that-also-extends-itself

PD: I’m using Twig template and Symfony2

  • 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-15T00:13:57+00:00Added an answer on June 15, 2026 at 12:13 am

    You could have a separate template for printing object map and, as you guessed, this would have to be done using AJAX. You would pass the data you want to show on map (not id as you don’t want to query database again) and the controller would return formatted HTML.

    However, this seems to me a bit overkill. I would always consider doing JS (with optional framework) in order to swap the content of sidebar with Map object.

    It really depends on which map API do you use. If it could be controlled via JS I would look no further. It it could not, well then, AJAX is your natural choice….

    UPDATE:

    OK, what you should do is create initial Map object that will be modified later on:

    var theMap = null;
    
    function initializeMap(){
        var mapOptions = {
        center: new google.maps.LatLng(some_latitude, some_longitude),
            zoom: 8, // goes from 0 to 18
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        theMap = new google.maps.Map(document.getElementById("map_canvas"),mapOptions);
        // you must have some element with ID = 'map_canvas'
    }
    

    some_latitude and some_longitude are fairly unimportant as you will most likely set new coordinates in a few moments.

    Now assuming (but not crucial at all) that you use some of the JS frameworks (I prefer jQuery) you could bind click event to those location links:

    var onlyMarker = null;
    $('.location').click(function(){
        var $t = $(this);
        var newLatLang = new google.maps.LatLng($t.attr('data-lat') ,$t.attr('data-lng'));
    
        if ( onlyMarker  == null ) {
            onlyMarker = new google.maps.Marker({
                position: newLatLang
                map: theMap,
                title:  $t.attr('title')
            });
         }else{
            onlyMarker.setPosition(newLatLang);
         }
    });
    

    Now, relying on HTML5’s ‘data-*’ attibutes is not good idea in particular as if you use any other version lower you will most likely end-up with invalid markup. The workaround is to for link (<a>) to carry id/key to LatLng object, for example:

    // initially generated from `AJAX` or in `Twig` loop
    var allLatlangs = [ 
        new google.maps.LatLngf(some_latitude, some_longitude),
        new google.maps.LatLngf(some_latitude, some_longitude),
        new google.maps.LatLngf(some_latitude, some_longitude),
    ];
    
    $('.location').click(function(){
        var id = $(this).attr('id');
         var newLatLang = allLatLang(id);
         //....
         // everything else is the same 
         // ....
    });
    

    Don’t forget to include Maps API with proper API key:

    https://maps.googleapis.com/maps/api/js?key=API_KEY_HERE&sensor=true
    

    In order to obtain valid API key follow this link: API KEY HOW-TO

    This link basically covers key steps that I have described here so study it and it should all come together nicely.

    Also, if you’re unsure how to retrieve some things from Maps you should consult reference:
    REFERENCE which has every method call described pretty good

    Remember not to execute any of this code until everything is being loaded.

    Hope this helped a bit 🙂

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I want to show the soap response to UIWebview.. my soap response is, <p><img
This could be a duplicate question, but I have no idea what search terms
I have an array which has BIG numbers and small numbers in it. I

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.