Here is my form code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="GoogleMaps._Default" %>
<%@ Register src="GoogleMapsControl.ascx" tagname="GoogleMapsControl" tagprefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>UPR-B</title>
<link type="text/css" rel="stylesheet" href="styles/styles.css" />
</head>
<body>
<div id="wrapper">
<form id="frmGMap" runat="server" >
<div id="gMap">
<asp:PlaceHolder ID="phGMap" runat="server"></asp:PlaceHolder>
</div>
<asp:DropDownList ID="ddlPlace" runat="server" onselectedIndexChange="Index_Changed" AutoPostBack="true">
<asp:ListItem>Edificio 100</asp:ListItem>
<asp:ListItem>Edificio 200</asp:ListItem>
<asp:ListItem>Edificio 300</asp:ListItem>
<asp:ListItem>Edificio 400</asp:ListItem>
<asp:ListItem>Edificio 500</asp:ListItem>
<asp:ListItem>Edificio 600</asp:ListItem>
<asp:ListItem>Edificio 700</asp:ListItem>
<asp:ListItem>Edificio 800</asp:ListItem>
<asp:ListItem>Centro Estudiantes</asp:ListItem>
</asp:DropDownList>
</form>
</div>
</body>
</html>
Code file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace GoogleMaps
{
public partial class _Default : System.Web.UI.Page
{
private GoogleMaps.GoogleMapsControl gmc;
protected void Page_Load(object sender, EventArgs e)
{
gmc = (GoogleMaps.GoogleMapsControl)LoadControl("~/GoogleMapsControl.ascx");
setMap(18.371408, -66.143643, true, "Universidad de Puerto Rico en Bayamón", "");
}
private void setMap(double latitud, double longitud, bool pushPin, string pushPinTitle, string pushPinDescription) {
gmc.ID = "gMapID";
gmc.MapHeight = "700px";
gmc.MapWidth = "700px";
gmc.zoom = 17;
gmc.mapStyle = GoogleMaps.GoogleMapsControl.MapStyle.G_SATELLITE_MAP;
gmc.latitude = (decimal)latitud;
gmc.longitude = (decimal)longitud;
gmc.pushPin = pushPin;
gmc.pushPinTitle = pushPinTitle;
gmc.pushPinDescription = pushPinDescription;
phGMap.Controls.Add(gmc);
}
protected void Index_Changed(Object sender, EventArgs e)
{
int sel = ddlPlace.SelectedIndex + 1;
switch (sel)
{
case 1:
{ setMap(18.37093, -66.143279, true, "Edificio 100", ""); }
break;
case 2:
{ setMap(18.371785, -66.143794, true, "Edificio 200", ""); }
break;
case 3:
{ setMap(18.371235, -66.142946, true, "Edificio 300", ""); }
break;
case 4:
{ setMap(18.372029, -66.143334, true, "Edificio 400", ""); }
break;
case 5:
{ setMap(18.370762, -66.143841, true, "Edificio 500", ""); }
break;
case 6:
{ setMap(18.37093, -66.143279, true, "Edificio 600", ""); }
break;
case 7:
{ setMap(18.370599, -66.14415, true, "Edificio 700", ""); }
break;
case 8:
{ setMap(18.371411, -66.144657, true, "Edificio 800", ""); }
break;
default: setMap(18.372414, -66.143994, true, "Centro Estudiantes", "");
break;
}
Response.Redirect("Default.aspx");
}
}
}
I included everything in my project in the zip just in case anyone wanted to try it locally.
Thanks in advance.
Attached File(s)
-
GoogleMaps.zip (9.69K)
Number of downloads: 63
This post has been edited by cabbae2: 06 November 2011 - 01:38 PM

New Topic/Question
Reply



MultiQuote





|