Autor: subgurim
Publicado: 2007-01-17
Leído: 9559 veces
|
Comentarios (0)
Valoracion: 9,294348
|
/**** Explicación / Description
****/ Castellano Ejemplo de cómo hacer clic, crear un icono y si presionamos sobre el icono hacer de éste el centro del mapa. En este caso no se hace ningún viaje al servidor.
English Example of how to make a click, create a marker and, if we click it, make it the center of the map. All this done on client, without travelling to the server.
/**** Código de servidor / Server code
****/ using System;
using System.Text; using Subgurim.Controles;
public partial class Galeria_codigo_Ejemplos_ClickAndCenterClient : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GMarker mkr = new GMarker(); mkr.javascript_GLatLng = "point"; System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("function(marker, point) {"); sb.Append("if (marker){"); sb.AppendFormat("{0}.panTo(marker.getPoint());", GMap1.GMap_Id); //sb.AppendFormat("{0}.setCenter(marker.getPoint());", GMap1.GMap_Id); sb.Append("}"); sb.Append("else{"); sb.Append(mkr.ToString(GMap1.GMap_Id)); sb.Append("}"); sb.Append("}");
GListener listener2 = new GListener(GMap1.GMap_Id, GListener.Event.click, sb.ToString()); GMap1.addListener(listener2); } } }
/**** Código HTML / HTML Code
****/
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ClickAndCenterClient.aspx.cs" Inherits="Galeria_codigo_Ejemplos_ClickAndCenterClient" %>
<%@ Register Assembly="GMaps" Namespace="Subgurim.Controles" 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>Click And Center on Client</title> </head> <body> <form id="form1" runat="server"> <div> <cc1:GMap ID="GMap1" runat="server" Width="600px" Height="400px" /> </div> </form> </body> </html>
/**** Código Javascript / Javascript Code
****/
.aspx GMarker mkr = new GMarker(); mkr.javascript_GLatLng = "point"; System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("function(marker, point) {"); sb.Append("if (marker){"); sb.AppendFormat("{0}.panTo(marker.getPoint());", GMap1.GMap_Id); //sb.AppendFormat("{0}.setCenter(marker.getPoint());", GMap1.GMap_Id); sb.Append("}"); sb.Append("else{"); sb.Append(mkr.ToString(GMap1.GMap_Id)); sb.Append("}"); sb.Append("}");
GListener listener2 = new GListener(GMap1.GMap_Id, GListener.Event.click, sb.ToString()); GMap1.addListener(listener2);
|
|