¡Ayúdanos a traducir esta Web y consigue licencias gratis!
Usuario anónimo  |  Ingresar  |  Regístrate

Custom Maps

Con los CustomMaps podremos definir las imágenes que mostrará el control de Google en base a la latitud, longitud y zoom en la que estemos.

Utilizaremos las clases GCopyright, GCopyrightCollection, GTileLayerOptions, GTileLayer y GCustomMapType. Su uso es muy sencillo y vale seguir el ejemplo para entenderlo.

El elemento más importante es la correcta definición de la propiedad tileUrlTemplate del GTileLayerOptions. Se trata de un template que define la URL de la imagen a la que GoogleMaps va a llamar y será la que debéis gestionar. Tiene la siguiente estructura: http://host/tile?x={X}&y={Y}&z={Z}.png Donde X es la latitud, Y es la longitud y Z es el zoom. Un ejemplo sería: http://host/tile?x=3&y=27&z=5.png




Code.aspx
<cc1:GMap ID="GMap1" runat="server" />
Code.aspx.cs
GMap1.setCenter(new GLatLng(37.4419, -122.1419), 13);


GCopyrightCollection myCopyright = new GCopyrightCollection("© ");
myCopyright.Add(new GCopyright("Demo",
                                new GLatLngBounds(new GLatLng(-90, -180), new GLatLng(90, 180)),
                                0,
                               "©2008 Subgurim"));


GTileLayerOptions tileLayerOptions = new GTileLayerOptions();
tileLayerOptions.tileUrlTemplate = "http://code.google.com/apis/maps/documentation/examples/include/tile_crosshairs.png";

GTileLayer tilelayer = new GTileLayer(myCopyright, 10, 10, tileLayerOptions);


GCustomMapType customMapType = new GCustomMapType(tilelayer, new GMercatorProjection(13), "Subgurim");
GMap1.Add(customMapType);
Powered by Subgurim.NET