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

DataSource

GoogleMaps.subgurim.NET has support for DataSource. This one works just like the one of any other element that supports DataSource like a ListBox, a GridView, a ChekList, etc. For example, we can assign a generic listing or dataset like "DataSource" or SqlDataSource or ObjectDataSource like "DataSourceID".

In principle, and subject to future extensions, we can assign 3 fields to it:
  • DataLatField: indicates the name of the field that contains the "double" with the latitude of the point. It is a mandatory field. If nothing is entered, "lat" will be 0.
  • DataLngField: indicates the name of the field that contains the "double" with the length of the point. It is a mandatory field. If nothing is entered, "lng" will be 0.
  • DataGInfoWindowTextField: if we want the icon defined in both previous fields in a GInfoWindow leaves, enter a string. It will correspond with the GInfoWindow value in HTML format. Therefore, "DataGInfoWindowTextField" indicates the name of the field that contains the string with the GInfoWindow Html. If this field does not exist or is empty, no GInfoWindow will be opened.
  • DataGIconImageField: if we want a custom GIcon, que should indicate the field that contains the Image Path.
  • DataGIconShadowField: if we want a custom GIcon, que should indicate the field that contains the Shadow Path.
  • DataGIconAnchorField: if we want a custom GIcon, que should indicate the field that contains the Image Anchor. e.g.: 6,20
  • DataGIconSizeField: if we want a custom GIcon, que should indicate the field that contains the Image Size. e.g.: 12,20
  • DataGIconShadowSizeField: Si queremos un icono debemos indicar el nombre del campo que contiene el size de la sombra. e.g.: 22,20
  • DataGInfoWindowAnchorField: Si queremos un infowindow, debemos indicar el nombre del campo que contiene el anchor de la imagen. e.g.: 5,1
We can define what the points mean with the DataSourceType property. We have many options: Markers (by default), Polygons, Polylines, PolygonsAndMarkers and PolylinesAndMarkers

As a GPolygon and a GPolyline are very customizables, we can set a  GPolygon/GPolyline template with the properties DataSourceGPolygonBase and DataSourceGPolylineBase.

In order to make this easy, the "DataSourceField" class has been created, in which the properties have the same name that the values by as the fields.

Like always, the example will clarify more ideas to us than the explanation.




Code.aspx
<cc1:GMap ID="GMap1" runat="server"
    DataSourceID="SqlDataSource1" DataSourceType="PolylinesAndMarkers" 
    DataLatField="Lat" DataLngField="Lng" DataGInfoWindowTextField="InfoWindowText" 
    DataGIconImageField="IconImage" DataGIconShadowField="IconShadow" 
    DataGIconAnchorField="IconAnchor" DataGIconSizeField="IconSize" DataGIconShadowSizeField="IconShadowSize" DataGInfoWindowAnchorField="InfoWindowAnchor" />


<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MapTest %>"
    SelectCommand="SELECT Lat, Lng, InfoWindowText, IconImage, IconShadow, IconAnchor, IconSize, IconShadowSize, InfoWindowAnchor FROM [MapTestTable]"></asp:SqlDataSource>

Powered by Subgurim.NET