title: Pinpoint locations on google maps using ASP.NET
body: <p>I am trying to pinpoint locations on google (or bing) maps, and I'm unable to do so in both. The code structure is similar in both, and I present the google maps attempt:</p>
  
  <p>The objective: I have a linked list of Objects, each of which contain latitude and longitude, all of which have to be pinpointed.</p>
  
  <p>Full ASP: <a href="http://pastie.org/7752124" rel="nofollow">http://pastie.org/7752124</a> (The repeater is to present the search results)</p>
  
  <p>Relevant (in head):</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      var map = null;
      function initialize() {
          var mapOptions = {
              center: new google.maps.LatLng(40.42, -98.737),
              zoom: 4,
              mapTypeId: google.maps.MapTypeId.ROADMAP
          };
          map = new google.maps.Map(document.getElementById("map-canvas"),
          mapOptions);
          //pushPin(25, 80);
      }
      function pushPin(lat, lon) {
          alert(lat + " " + lon);
          var myLatlng = new google.maps.LatLng(lat, lon);
          var marker = new google.maps.Marker({
              position: myLatlng,
              map: map,
              title: "Hello World!"
          });
      }
      google.maps.event.addDomListener(window, 'load', initialize);
  &lt;/script&gt;
  </code></pre>
  
  <p>Codebehind: 
  Activated when user clicks the search button:</p>
  
  <pre><code>protected void Button1_Click(object sender, EventArgs e)
      {
          List&lt;Results&gt; rlist = getResults(query);
          String Locations = "";
          foreach (Results res in rlist)
          {
              Page.ClientScript.RegisterStartupScript(
                  GetType(),
                  "MyKey",
                  "pushPin("+res.latitude+","+res.longitude+");",
                  true);
          }
          this.rptREsults.DataSource = rlist;
          this.rptREsults.DataBind();
      }
  
  public class Results
  {
      public string filename { get; set; }
      public string asciiname { get; set; }
      public string latitude { get; set; }
      public string longitude { get; set; }
  }
  </code></pre>
  
  <p>The results are correct and do contain latitude and longitude, and when I put an alert in the pushPin method, only one alert box comes, but no pinpoint is created. Is there a better way to store and pinpoint a list of Latitudes and Longitudes?</p>
  
  <p>The pushPin method works when I call it from another javascript method. </p>