Help us translate this website and improve this translation and earn free licenses!
Anonymous user  |  Log in  |  Create Account

TileLayers

With TileLayers we can define our custom layers on the map, so we can superimpose our images to the ones returned by GoogleMaps.

To define those layers we use the GCopyright, GCopyrightCollection, GTileLayerOptions, GTileLayer, and GTileLayerOverlay classes. They're very easy to use, and the example is more than enough to understand them.

The most important isue is the correct definition for the tileUrlTemplate property of GTileLayerOptions. It's a template the defines the URL for the image called by GoogleMaps, which we have to manage. The structure is the following: http://host/tile?x={X}&y={Y}&z={Z}.png Where X is latitude, Y is longitude and Z is zoom. An example can be 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);

GTileLayerOverlay myTileLayer = new GTileLayerOverlay(tilelayer);

GMap1.Add(myTileLayer);
Powered by Subgurim.NET