ASP.net Page----------------------- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Home.aspx.cs" Inherits="SampleMap.Home" %> <%@ Register Assembly="Artem.GoogleMap" Namespace="Artem.Web.UI.Controls" TagPrefix="cc1" %> <!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 id="Head1" runat="server"> <title>Google Map Tutorial</title> <link href="css/default.css" rel="stylesheet" type="text/css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> function getLatLongValues(overlay, point) { if (point) { document.getElementById("latValue").value = point.lat(); document.getElementById("lngValue").value = point.lng(); document.forms[0].submit(); } } function setFocus(controlName) { document.getElementById(controlName).focus(); } function windowHeight() { return (window.height() - 50) + "px"; } </script> </head> <body önload="setFocus('txtCity');"> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> City name or address: <asp:TextBox ID="txtCity" runat="server"> <asp:Button ID="btnSearch" runat="server" Text="Go" onclick="btnSearch_Click" /> <asp:Button ID="btnMove" runat="server" Text="Move" onclick="btnMove_Click" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <cc1:GoogleMap ID="mapControl" runat="server" Width="100%" Height="740px" Zoom="3" Latitude="14.560753" Longitude="121.013811" ForeColor="#333300" InsideUpdatePanel="True" IsSensor="True" ShowTraffic="True"> <asp:HiddenField ID="latValue" runat="server" /> <asp:HiddenField ID="lngValue" runat="server" /> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Artem.Web.UI.Controls; namespace SampleMap { public partial class Home : System.Web.UI.Page { static double lat = 14.561438; static double lng = 121.027800; GoogleMarker marker = new GoogleMarker(lat, lng); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CheckForClickLocation(); } } protected void btnMove_Click(object sender, EventArgs e) { CheckForClickLocation(); //UpdatePanel1.Update(); } protected void btnSearch_Click(object sender, EventArgs e) { // First clear old markers since this is a new search mapControl.Markers.Clear(); if (txtCity.Text != "") { mapControl.Address = txtCity.Text; mapControl.Zoom = 18; // add a new search marker GoogleMarker marker = new GoogleMarker(mapControl.Address); marker.Title = mapControl.Address; marker.Clickable = true; marker.Bouncy = true; //marker.InfoContent = mapControl.Address; mapControl.Markers.Add(marker); } } private void CheckForClickLocation() { marker.Clickable = true; marker.OpenInfoWindow(mapControl.Address); marker.Title = mapControl.Address; mapControl.Markers.Add(marker); mapControl.Latitude = marker.Latitude + .3; mapControl.Longitude = marker.Longitude + .3; mapControl.Zoom = 18; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)