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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:42:11+00:00 2026-06-12T23:42:11+00:00

i try this code for(i=0; i<num ;i++) { points.push([lats[i], lngs[i]]); if(i==0) str = ‘S’;

  • 0

i try this code

for(i=0; i<num ;i++)
{
    points.push([lats[i], lngs[i]]);

    if(i==0) str = 'S';
    else if(i==num-1) str = 'E';
    else str = '';

    var marker = new nokia.maps.map.Marker(
            [lats[i], lngs[i]],
            {
                    title: str,
                    visibility: true,
                    icon: img,
                    anchor: new nokia.maps.util.Point(5, 5)
            });
    marker.addListener('click', function(evt){
            $('.loc').html(times[i]);
    });
    map.objects.add(marker);
}

but it just does not fire click event. is anything wrong with code?

lats and lngs and times are defined and points is to be used later.

Edit:

Problem solved. See comment for answer below.

  • 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-12T23:42:13+00:00Added an answer on June 12, 2026 at 11:42 pm

    It looks like the problem is with the line:

    $('.loc').html(times[i]);
    

    Within the marker listener. The event hasn’t got access to the array element when it is fired and therefore fails. I think you need to add an attribute to the marker and access it as shown:

    var marker = new nokia.maps.map.Marker(
                [lats[i], lngs[i]],
                {
                        title: str,
                        visibility: true,
                        icon: img,
                        anchor: new nokia.maps.util.Point(29, 71),
                        $html : times[i]
                });
        marker.addListener('click', function(evt){
                //$('.loc').html(times[i]); 
               alert (evt.target.$html);
        });
    

    Try the following (with your own App Id and token of course):

    <!DOCTYPE HTML SYSTEM>
    <html>
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <meta http-equiv="X-UA-Compatible" content="IE=7; IE=EmulateIE9" />
            <script type="text/javascript" charset="UTF-8" src="http://api.maps.nokia.com/2.2.3/jsl.js"></script>
    
    
            <style type="text/css">
    
                html {
                    overflow:hidden;
                }
    
                body {
                    margin: 0;
                    padding: 0;
                    overflow: hidden;
                    width: 100%;
                    height: 100%;
                    position: absolute;
                }
    
                #mapContainer {
                    width:100%;
                    height: 100%;
                    left: 0;
                    top: 0;
                    position: absolute;
                }
    
     </style>
        </head>
        <body>
            <div id="mapContainer"></div>
            <script type="text/javascript">
    
                nokia.Settings.set( "appId", "YOUR APP ID GOES HERE"); 
                nokia.Settings.set( "authenticationToken", "YOUR AUTHENTICATION TOKEN GOES HERE");
    
    var mapContainer = document.getElementById("mapContainer");
    
    
    var DefaultLatitude = 52.516237;
    var DefaultLongitude = 13.377686;
    var defaultZoomLevel = 16;
    
    var mapOptions =
    {
        baseMapType: nokia.maps.map.Display.NORMAL,
        center: new nokia.maps.geo.Coordinate(DefaultLatitude, DefaultLongitude),    
        zoomLevel: defaultZoomLevel,
        components: [
            new nokia.maps.map.component.ZoomBar(),
            new nokia.maps.map.component.Behavior(),
            new nokia.maps.map.component.Overview(),
            new nokia.maps.map.component.ScaleBar(),
            new nokia.maps.map.component.ContextMenu()
        ]
    };
    
      var map = new nokia.maps.map.Display(mapContainer, mapOptions);
    
    
    
    var str ="";
    var img = "http://api.maps.nokia.com/en/playground/examples/maps/res/markerHouse.png";
    var points= new Array();
    var lats = new Array();
    var lngs = new Array();
    var times = new Array();
    var num;
    
    lats[0] = 52.516237;
    lngs[0] = 13.377686;
    times[0] = "brandenburg gate";
    num = 1;
    for(var i=0; i<num ;i++)
    {
        points.push([lats[i], lngs[i]]);
    
        if(i==0) str = 'S';
        else if(i==num-1) str = 'E';
        else str = '';
    
        var marker = new nokia.maps.map.Marker(
                [lats[i], lngs[i]],
                {
                        title: str,
                        visibility: true,
                        icon: img,
                        anchor: new nokia.maps.util.Point(29, 71),
                        $html : times[i]
                });
        marker.addListener('click', function(evt){
                //$('.loc').html(times[i]); 
               alert (evt.target.$html);
        });
        map.objects.add(marker);
    }
    
     </script>
        </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: try { var _o, _l, i, _d = new Array(),
This code: print( - Start); int[] num = new int[] {1,2,3,4,5,6,7,8,9,10}; for(int i :
Try this code - import java.io.StringReader; public class StringReaderTest { public static void main(String[]
When I try this code: dict_a = dict_b = dict_c = {} dict_c['hello'] =
When I try this code: if Verbose: print("Building internam Index for %d tile(s) ..."
I want to make this 1332251639632 to this 1332251639 I try this code, but
Try this piece of code - public class WhitespaceTest { public static void main(String[]
I have this code try { //AN EXCEPTION IS GENERATED HERE!!! } catch {
When I try to compile this code: struct BasicVertexProperties { Vect3Df position; }; struct
When I try to run this code, I get incorrect maximums and minimums. Could

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.