SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Wizard dethfire's Avatar
    Join Date
    Aug 2000
    Posts
    2,477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    googlemap api question

    how do I get the marker window to show automaticly, not "onclick"?
    Free Science Homework Help
    http://www.physicsforums.com

  2. #2
    SitePoint Wizard dethfire's Avatar
    Join Date
    Aug 2000
    Posts
    2,477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAXnRe7KxqfmSKuX8ohrbsFRTwZaaivImGX9xkH6dGzxUoTNbrNhSapuaxqDjbAa-EReilbcyWrTm_OQ"
          type="text/javascript"></script>
        <script type="text/javascript">
        //<![CDATA[
        function load() {
          if (GBrowserIsCompatible()) {
            var map = new GMap2(document.getElementById("map"));
    		map.addControl(new GSmallMapControl());
    		map.addControl(new GMapTypeControl());
            map.setCenter(new GLatLng(44.976618, -93.268382), 15);
                      
    		var marker = new GMarker(new GLatLng(44.976618, -93.268382));
          GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml("<b>Moore and Hansen</b> <br> 225 South 6th Street 48th Floor<br> Minneapolis, MN 55402<br><a href='http://maps.google.com/maps?saddr=225 South 6th Street Minneapolis, MN 55402&daddr='>Get Directions</a>");
          });
          map.addOverlay(marker);
    
    
          }
        }
        //]]>
        </script>
    If I don't add the "GEvent.addListener" function the marker doesn't show up.
    Free Science Homework Help
    http://www.physicsforums.com

  3. #3
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just leave out the addListener wrapper:
    Code:
    var marker = new GMarker(new GLatLng(44.976618, -93.268382));
    marker.openInfoWindowHtml("<b>Moore and Hansen</b> <br> 225 South 6th Street 48th Floor<br> Minneapolis, MN 55402<br><a href='http://maps.google.com/maps?saddr=225 South 6th Street Minneapolis, MN 55402&daddr='>Get Directions</a>");
    map.addOverlay(marker);


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
  •