I'm pretty new to this API however I am currently working on this type
of app.
I am sure there are more ellagant ways of doing this but I am
basically generating the javascript server side.

Client site page:
----------------------------------------------------------------------
<head runat="server">
    <title>mapDotNetTest</title>

    <script src="http://maps.google.com/maps?
file=api&amp;v=2&amp;key=YOUR API KEY"
        type="text/javascript"></script>

    <script type="text/javascript">
        function getBaseIcon(){
        // Create a base icon for all of our markers that specifies
the
        // shadow, icon dimensions, etc.
        var baseIcon = new GIcon(G_DEFAULT_ICON);
        baseIcon.shadow = "http://www.google.com/mapfiles/
shadow50.png";
        baseIcon.iconSize = new GSize(20, 34);
        baseIcon.shadowSize = new GSize(37, 34);
        baseIcon.iconAnchor = new GPoint(9, 34);
        baseIcon.infoWindowAnchor = new GPoint(9, 2);

        return baseIcon;
        }

        function createMarker(latitude, longitude, index, popuptext) {
         var point = new GLatLng(latitude,longitude);
          // Create a lettered icon for this point using our icon
class
          var letter = String.fromCharCode("A".charCodeAt(0) + index);
          var letteredIcon = new GIcon(getBaseIcon());
          letteredIcon.image = "http://www.google.com/mapfiles/marker";
+ letter + ".png";

          // Set up our GMarkerOptions object
          markerOptions = { icon:letteredIcon };
          var marker = new GMarker(point, markerOptions);

          GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml(popuptext);
          });
          return marker;
        }
    </script>

</head>
<body  onload="initialize()" onunload="GUnload()">
    <form id="form1" runat="server">
        <div>
            <asp:Label ID="Label1" runat="server" Text="Zip Code: "></
asp:Label>
            <asp:TextBox ID="EnteredZip" runat="server"></
asp:TextBox><br />
            <asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="LoadMap" /><br />
            <div id="map_canvas" style="width: 600px; height: 400px">
            </div>
            </div>
    </form>
</body>
</html>
----------------------------------------------------
c# code:
public partial class mapDotNETtest : System.Web.UI.Page
{
    const string createOverlay = @"map.addOverlay(createMarker({0},{1},
{2},{3}));";
    protected void Page_Load(object sender, EventArgs e)
    {


    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //just testing so far but this will tie to users entered zip
code... the ZipCode class is just returing the lat. and long. of the
center of the zipcode...
        ZipCode lZip = new ZipCode();
        lZip.setZipLocation("01010");
        string lng = lZip.Longitude.ToString();
        string lat = lZip.Latitude.ToString();

        StringBuilder jScript = new StringBuilder();

        jScript.Append("<script type=\"text/javascript\"> function
initialize() {");
        jScript.Append("if (GBrowserIsCompatible()) { ");
        jScript.Append("var map = new GMap2(document.getElementById
('map_canvas')); ");
        jScript.Append("map.setCenter(new GLatLng(" +
lZip.Latitude.ToString() + "," + lZip.Longitude.ToString() + "),
15);");
        jScript.Append("map.addControl(new GSmallMapControl()); ");
        jScript.Append("map.addControl(new GMapTypeControl()); ");
        jScript.Append(buildLocations());
        jScript.Append("}}");
        jScript.Append("</script>");

        this.ClientScript.RegisterClientScriptBlock(this.GetType
(),"initialize", jScript.ToString(),false);
    }
    protected string buildLocations()
    {

        StringBuilder locations = new StringBuilder();
        // this will be a loop of retrieving the data from the
database...)
        locations.Append(string.Format(createOverlay, "45.852728",
"-92.653866", "0", "'Home'"));

        return locations.ToString();

    }
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to