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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:41:05+00:00 2026-06-05T20:41:05+00:00

How can I add different markers to google map v3? Here is example for

  • 0

How can I add different markers to google map v3?

Here is example for my marker:

var latlng = new google.maps.LatLng(lat,lng); 
var image = "../img/hotel_icon.png";
var locationDescription = this.locationDescription;
var marker = new google.maps.Marker({
  map: map,
  position: latlng,
  title:'pk:'+name,
  icon: image
});

bounds.extend(latlng);
setMarkes(map, marker, name, locationDescription);

});//close each
map.fitBounds(bounds);
});//close getjson

}//close initialize
function setMarkes(map, marker, name, locationDescription){
  google.maps.event.addListener(marker, 'mouseover', function() {
      infowindow.close();
      infowindow.setContent('<h3>'+name+'</h3><em>'+locationDescription+'</em>');
      infowindow.open(map, marker);
  });

}
  • 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-05T20:41:07+00:00Added an answer on June 5, 2026 at 8:41 pm

    Here is one example that may help:
    http://www.geocodezip.com/v3_markers_normal_colored_infowindows.html

    code snippet:

    function initialize() {
      var myOptions = {
        zoom: 10,
        center: new google.maps.LatLng(-33.9, 151.2),
        mapTypeControl: true,
        mapTypeControlOptions: {
          style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
        },
        navigationControl: true,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      }
      var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
    
      google.maps.event.addListener(map, 'click', function() {
        infowindow.close();
      });
      setMarkers(map, beaches);
    }
    var icons = new Array();
    icons["red"] = new google.maps.MarkerImage("http://www.geocodezip.com/mapIcons/marker_red.png",
      // This marker is 20 pixels wide by 34 pixels tall.
      new google.maps.Size(20, 34),
      // The origin for this image is 0,0.
      new google.maps.Point(0, 0),
      // The anchor for this image is at 9,34.
      new google.maps.Point(9, 34));
    
    function getMarkerImage(iconColor) {
      if ((typeof(iconColor) == "undefined") || (iconColor == null)) {
        iconColor = "red";
      }
      if (!icons[iconColor]) {
        icons[iconColor] = new google.maps.MarkerImage("http://www.geocodezip.com/mapIcons/marker_" + iconColor + ".png",
          // This marker is 20 pixels wide by 34 pixels tall.
          new google.maps.Size(20, 34),
          // The origin for this image is 0,0.
          new google.maps.Point(0, 0),
          // The anchor for this image is at 6,20.
          new google.maps.Point(9, 34));
      }
      return icons[iconColor];
    
    }
    // Marker sizes are expressed as a Size of X,Y
    // where the origin of the image (0,0) is located
    // in the top left of the image.
    
    // Origins, anchor positions and coordinates of the marker
    // increase in the X direction to the right and in
    // the Y direction down.
    
    var iconImage = new google.maps.MarkerImage('http://www.geocodezip.com/mapIcons/marker_red.png',
      // This marker is 20 pixels wide by 34 pixels tall.
      new google.maps.Size(20, 34),
      // The origin for this image is 0,0.
      new google.maps.Point(0, 0),
      // The anchor for this image is at 9,34.
      new google.maps.Point(9, 34));
    var iconShadow = new google.maps.MarkerImage('http://www.google.com/mapfiles/shadow50.png',
      // The shadow image is larger in the horizontal dimension
      // while the position and offset are the same as for the main image.
      new google.maps.Size(37, 34),
      new google.maps.Point(0, 0),
      new google.maps.Point(9, 34));
    // Shapes define the clickable region of the icon.
    // The type defines an HTML &lt;area&gt; element 'poly' which
    // traces out a polygon as a series of X,Y points. The final
    // coordinate closes the poly by connecting to the first
    // coordinate.
    var iconShape = {
      coord: [9, 0, 6, 1, 4, 2, 2, 4, 0, 8, 0, 12, 1, 14, 2, 16, 5, 19, 7, 23, 8, 26, 9, 30, 9, 34, 11, 34, 11, 30, 12, 26, 13, 24, 14, 21, 16, 18, 18, 16, 20, 12, 20, 8, 18, 4, 16, 2, 15, 1, 13, 0],
      type: 'poly'
    };
    var infowindow = new google.maps.InfoWindow({
      size: new google.maps.Size(150, 50)
    });
    
    function createMarker(map, latlng, label, html, color) {
      var contentString = '<b>' + label + '</b><br>' + html;
      var marker = new google.maps.Marker({
        position: latlng,
        map: map,
        shadow: iconShadow,
        icon: getMarkerImage(color),
        shape: iconShape,
        title: label,
        zIndex: Math.round(latlng.lat() * -100000) << 5
      });
    
      google.maps.event.addListener(marker, 'click', function() {
        infowindow.setContent(contentString);
        infowindow.open(map, marker);
      });
    }
    
    /**
     * Data for the markers consisting of a name, a LatLng and a zIndex for
     * the order in which these markers should display on top of each
     * other.
     */
    var beaches = [
      ['Bondi Beach', -33.890542, 151.274856, "red"],
      ['Coogee Beach', -33.923036, 151.259052, "blue"],
      ['Cronulla Beach', -34.028249, 151.157507, "green"],
      ['Manly Beach', -33.80010128657071, 151.28747820854187, "yellow"],
      ['Maroubra Beach', -33.950198, 151.259302, "orange"]
    ];
    
    function setMarkers(map, locations) {
      // Add markers to the map
    
      for (var i = 0; i < locations.length; i++) {
        var beach = locations[i];
        var myLatLng = new google.maps.LatLng(beach[1], beach[2]);
        var marker = createMarker(map, myLatLng, beach[0], beach[0], beach[3]);
      }
    }
    google.maps.event.addDomListener(window, 'load', initialize);
    html,
    body {
      height: 100%;
      height: 100%;
      padding: 0;
      margin: 0
    }
    
    #map_canvas {
      width: 100%;
      height: 100%;
    }
    <div id="map_canvas"></div>
    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script>
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I add more Markers to Google Map with different icon types like: ...
I'm trying to add markers to a map on my page using Google's Javascript
I'm developing an App where the user can add Different logo (drawable) on a
I'm working on an advanced map application in Google Maps API V3. I'm using
I want to display different markers on my map. One solution I could find
can you add different class objects to same list?
How can I add the same text(s) to two or more different lists? For
Can someone please help me with how I can add several different queries to
I would like to ask about how can I add different overlays to my
These are three different things you can add to a project and I am

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.