Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User amnesia7's Avatar
    Join Date
    Dec 2011
    Posts
    13
    Is there any chance someone could knock up a quick example of a map with multiple markers in a marker container and a remove button that clears all markers and infobubbles.

    I know there's a similar example in the "playground" but it's just too complicated for me to understand because it allows markers to be created on-the-fly. I want to know how to load markers onto the map normally but allow a button to remove all markers and infobubbles from the map.

  2. #2
    Nokia Developer Expert JoergHoesel's Avatar
    Join Date
    Nov 2010
    Posts
    1
    Hi there,

    to get a map with markers in a container and have infobubbles do this:
    Code:
    var infoBubbles = new nokia.maps.map.component.InfoBubbles(),
        map = new nokia.maps.map.Display(myMapContainerDiv, {
            components: [infoBubbles]
        }),
        markerContainer = new nokia.maps.map.Container(),
        i = 100;
    //add event listener on the marker to open the bubble
    markerContainer.addListener("click", function(evt) {
        var marker = evt.target;
        infoBubbles.addBubble(marker.$infoBubbleText, marker.coordinate);
    });
    
    //add 100 markers (may be sensible to use different coordinates than always the map's center)
    while(i--) {
        markerContainer.objects.add(new nokia.maps.map.StandardMarker(map.center, {
            //custom property prefixed with $ to avoid overwriting StandardMarker properties
            $infoBubbleText: "This is marker " +  i
        }));
    }
    
    //finally add the container to the map
    map.objects.add(markerContainer);
    To remove you can do the following:
    Code:
    markerContainer.objects.clear();
    while(infoBubbles.openBubbleHandles.getLength() > 0) {
        infoBubbles.removeBubble(infoBubbles.openBubbleHandles.get(0));
    }
    Last edited by JoergHoesel; 2012-06-28 at 13:30.

  3. #3
    Registered User amnesia7's Avatar
    Join Date
    Dec 2011
    Posts
    13
    Great stuff, thanks.

    Sorted now!

    Col

Similar Threads

  1. Map markers not always shown when max zoomed out
    By amnesia7 in forum Maps API for Javascript
    Replies: 8
    Last Post: 2012-11-26, 21:06
  2. [moved] Mobile mh5 markers and infobubbles
    By pamepros in forum MH5: Nokia Maps Framework for mobile HTML5
    Replies: 25
    Last Post: 2012-07-30, 17:43
  3. How to Diplay infobubbles for the custom image marker in Nokia MAPs
    By Ulala in forum Geolocation and Navigation
    Replies: 2
    Last Post: 2012-02-28, 10:43
  4. Multiple markers at this line
    By jpytu in forum Symbian
    Replies: 1
    Last Post: 2010-05-27, 03:35
  5. Google Map URL J2ME markers
    By v2sms in forum Mobile Java General
    Replies: 1
    Last Post: 2010-02-15, 13:04

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved