SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2007
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adding multiple markers on google maps

    Hi there,

    I have a map in which displays a marker.

    How can I add multiple markers to the map?

    This is my code:

    PHP Code:
    var doncaster = new google.maps.LatLng(53.47921, -1.00201);
    var 
    parliament = new google.maps.LatLng(53.47921, -1.00201);
    var 
    marker;
    var 
    map;

    function 
    initialize() {
      var 
    mapOptions = {
        
    zoom14,
        
    mapTypeIdgoogle.maps.MapTypeId.ROADMAP,
        
    centerdoncaster
      
    };

      
    map = new google.maps.Map(document.getElementById('map-canvas'),
              
    mapOptions);

      
    marker = new google.maps.Marker({
        
    map:map,
        
    draggable:true,
        
    animationgoogle.maps.Animation.DROP,
        
    positionparliament
      
    });
      
    google.maps.event.addListener(marker'click'toggleBounce);
    }

    function 
    toggleBounce() {

      if (
    marker.getAnimation() != null) {
        
    marker.setAnimation(null);
      } else {
        
    marker.setAnimation(google.maps.Animation.BOUNCE);
      }
    }

    google.maps.event.addDomListener(window'load'initialize); 
    Thanks

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2004
    Location
    London, United Kingdom
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure but it looks like you just need to create second instance of google.maps.Marker...
    CodeReview4U - boost your code and skills for
    being social - JavsScript and C# code reviews.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •