SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist
    Join Date
    May 2007
    Location
    Montreal
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Google Maps Multiple Locations

    Hi

    I was wondering how I can post multiple locations on a google map that is embedded on my site?

    Thanks,
    Chris

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Keep creating new GMarker objects and calling map.addOverlay(marker). You can add thousands of markers to a map.

  3. #3
    SitePoint Evangelist
    Join Date
    May 2007
    Location
    Montreal
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cool....


    thanks Dan

  4. #4
    SitePoint Evangelist
    Join Date
    May 2007
    Location
    Montreal
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey

    Google maps has a geo code functions built in.

    I found a good example online
    http://code.google.com/apis/maps/doc...ng-simple.html

    But with this example, it works for searches only.
    How can I set it to place a marker without a search?

    I tried to call the following function and it didnt work:
    showAddress('1600 Amphitheatre Pky, Mountain View, CA');


    Any Ideas?

    Thanks,
    Chris


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Google Maps API Example: Simple Geocoding</title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAANhhZ1_UxyqAsJ0qQx9PH8RR7yJwutGzgsXuwh9w9g9mFepIvthSAvR6sY26bsLlkf7ER5QCC22VM_A" type="text/javascript"></script>
    <script type="text/javascript">

    var map = null;
    var geocoder = null;

    function initialize() {
    if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map_canvas"));
    map.setCenter(new GLatLng(37.4419, -122.1419), 13);
    geocoder = new GClientGeocoder();
    }
    }

    function showAddress(address) {
    if (geocoder) {
    geocoder.getLatLng(
    address,
    function(point) {
    if (!point) {
    alert(address + " not found");
    } else {
    map.setCenter(point, 13);
    var marker = new GMarker(point);
    map.addOverlay(marker);
    marker.openInfoWindowHtml(address);
    }
    }
    );
    }
    }
    </script>
    </head>

    <body onload="initialize()" onunload="GUnload()">


    <form action="#" onsubmit="showAddress(this.address.value); return false">
    <p>
    <input type="text" size="60" name="address" value="1600 Amphitheatre Pky, Mountain View, CA" />
    <input type="submit" value="Go!" />
    </p>
    <div id="map_canvas" style="width: 500px; height: 300px"></div>
    </form>
    <script type="text/javascript">
    showAddress('1600 Amphitheatre Pky, Mountain View, CA');
    </script>
    </body>
    </html>

  5. #5
    SitePoint Evangelist
    Join Date
    May 2007
    Location
    Montreal
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nevermind..... found it thanks


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
  •