×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    13

    Removal of infobubbles with a markers container

    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
    Join Date
    Nov 2010
    Posts
    1

    Re: Removal of infobubbles with a markers container

    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
    Join Date
    Dec 2011
    Posts
    13

    Re: Removal of infobubbles with a markers container

    Great stuff, thanks.

    Sorted now!

    Col

Similar Threads

  1. Map markers not always shown when max zoomed out
    By amnesia7 in forum [Archived] Maps API for Javascript
    Replies: 8
    Last Post: 2012-11-26, 21:06
  2. [moved] Mobile mh5 markers and infobubbles
    By pamepros in forum [Archived] MH5: Nokia Maps Framework for mobile HTML5
    Replies: 25
    Last Post: 2012-07-30, 17:43
  3. 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
  •  
×