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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:23:45+00:00 2026-06-08T18:23:45+00:00

I’m using Smarty, and I want to use google maps, and dynamicly place markers

  • 0

I’m using Smarty, and I want to use google maps, and dynamicly place markers on it, I got following cod

{literal}

 <script type="text/javascript">
    //<![CDATA[

    if (GBrowserIsCompatible()) {
      // ==== first part of the select box ===
      var select_html = '<select onChange="handleSelected(this)">' +
                        '<option selected> - Select a location - <\/option>';
      // =====================================
      var gmarkers = [];
      var htmls = [];
      var i = 0;
      var rozmiar = new google.maps.Size(12,20);  
                 var punkt_startowy = new google.maps.Point(0,0);  
                var punkt_zaczepienia = new google.maps.Point(0,0);  
                 var map;
      var n=0;
      var side_bar_html = "";


      var icon = new GIcon();
      icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
      icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
      icon.iconSize = new GSize(12, 20);
      icon.shadowSize = new GSize(22, 20);
      icon.iconAnchor = new GPoint(6, 20);
      icon.infoWindowAnchor = new GPoint(5, 1);      


      var ikona1 = new GIcon(icon,"http://labs.google.com/ridefinder/images/mm_20_blue.png"); 

      // A function to create the marker and set up the event window
      function createMarker(point,name,html,ikon) {
            var options = { 
draggable: true,
title: name,
icon: ikon,
clickable:true}
        var marker = new GMarker(point,options);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        gmarkers[i] = marker;
        htmls[i] = html;

        // ======= Add the entry to the select box =====
        select_html += '<option> ' + name + '<\/option>';
        // ==========================================================

        i++;
        map.addOverlay(marker);
        return marker;
      }


      // ======= This function handles selections from the select box ====
      // === If the dummy entry is selected, the info window is closed ==
      function handleSelected(opt) {
        var i = opt.selectedIndex - 1; 
        if (i > -1) {
          GEvent.trigger(gmarkers[i],"click");
        }
        else {
          map.closeInfoWindow();
        }
      }

        var wspolrzedne = new google.maps.LatLng(51.730430542940184,19.62158203125);

      // create the map
      var map = new GMap2(document.getElementById("map"));
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(51.730430542940184,19.62158203125), 6);

    {/literal}
    {foreach from=$znacznik key=key item=item}
    {foreach from=$item key=k item=v}
    //here
            createMarker(new GLatLng(51.730430542940184,19.62158203125),'{if $k == 'nazwa_obiektu'}{$v}{/if}','<div class="dymek"><div style="border-bottom:2px solid red;margin-bottom:6px;text-align:left;"><a href="http://nocleg-i.pl/{if $k == 'id'}{$v}{/if}/google_maps/" style="color:#2A86C7;font-size:13px;font-family:Verdana;font-weight:bold;">{if $k == 'nazwa_obiektu'}{$v}{/if}</a></div></strong><div style="float:left;width:125px;"><strong><a href="http://nocleg-i.pl/{if $k == 'id'}{$v}{/if}/google_maps/"><img src="http://nocleg-i.pl/uzytkownicy/miroslawa/mini_0.jpg" alt="" border="0" /></a></div>Miasto: {if $k == 'miasto'}{$v}{/if}</div></div><div style="clear:both;"></div>',ikona1);
    //here
    {/foreach}
    {/foreach}
    {literal}
            }else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }

    // This Javascript is based on code provided by the
    // Community Church Javascript Team
    // http://www.bisphamchurch.org.uk/   
    // http://econym.org.uk/gmap/

    //]]>
    </script>   
    {/literal}

between tags (//here)
these code is problem

createMarker(new GLatLng(51.730430542940184,19.62158203125),'{if $k == 'nazwa_obiektu'}{$v}{/if}','<div class="dymek"><div style="border-bottom:2px solid red;margin-bottom:6px;text-align:left;"><a href="http://nocleg-i.pl/{if $k == 'id'}{$v}{/if}/google_maps/" style="color:#2A86C7;font-size:13px;font-family:Verdana;font-weight:bold;">{if $k == 'nazwa_obiektu'}{$v}{/if}</a></div></strong><div style="float:left;width:125px;"><strong><a href="http://nocleg-i.pl/{if $k == 'id'}{$v}{/if}/google_maps/"><img src="http://nocleg-i.pl/uzytkownicy/miroslawa/mini_0.jpg" alt="" border="0" /></a></div>Miasto: {if $k == 'miasto'}{$v}{/if}</div></div><div style="clear:both;"></div>',ikona1);

It’s not showing variables for ex. {if $k == ‘nazwa_obiektu’}{$v}{/if} showing nothing, when I do foreach function somewhere else its showing variables, but if I type it by hand it showing it
Someone had idea how to solve it?

  • 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-08T18:23:46+00:00Added an answer on June 8, 2026 at 6:23 pm

    Check how your apostrophes are structured. Try this or look at {assign} to pre-set the values for javascript, and avoid the apostrophe confusion

    createMarker(
        new GLatLng(51.730430542940184,19.62158203125),
        '{if $k == "nazwa_obiektu"}{$v}{/if}',
        '<div class="dymek"><div style="border-bottom:2px solid red;margin-bottom:6px;text-align:left;"><a href=\"http://nocleg-i.pl/{if $k == "id"}{$v}{/if}/google_maps/\" style=\"color:#2A86C7;font-size:13px;font-family:Verdana;font-weight:bold;\">{if $k == "nazwa_obiektu"}{$v}{/if}</a></div></strong><div style=\"float:left;width:125px;\"><strong><a href=\"http://nocleg-i.pl/{if $k == "id"}{$v}{/if}/google_maps/\"><img src=\"http://nocleg-i.pl/uzytkownicy/miroslawa/mini_0.jpg\" alt=\"\" border=\"0\" /></a></div>Miasto: {if $k == "miasto"}{$v}{/if}</div></div><div style=\"clear:both;\"></div>',
        ikona1
    );
    

    or with {assign}

    {if $k == "nazwa_obiektu"}
        {assign var="nazwa_obiektu" value=$v}
    {/if}
    
    {if $k == "id"}
        {assign var="id" value=$v}
    {/if}
    
    {if $k == "miasto"}
        {assign var="miasto" value=$v}
    {/if}
    
        createMarker(
            new GLatLng(51.730430542940184,19.62158203125),
            '{$nazwa_obiektu|default}',
            '<div class="dymek"><div style="border-bottom:2px solid red;margin-bottom:6px;text-align:left;"><a href=\"http://nocleg-i.pl/{$id|default}/google_maps/\" style=\"color:#2A86C7;font-size:13px;font-family:Verdana;font-weight:bold;\">{$nazwa_obiektu|default}</a></div></strong><div style=\"float:left;width:125px;\"><strong><a href=\"http://nocleg-i.pl/{$id|default}/google_maps/\"><img src=\"http://nocleg-i.pl/uzytkownicy/miroslawa/mini_0.jpg\" alt=\"\" border=\"0\" /></a></div>Miasto: {$miasto|default}</div></div><div style=\"clear:both;\"></div>',
            ikona1
        );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I want use html5's new tag to play a wav file (currently only supported
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.