Databinding

Jun 23, 2010 at 6:30 PM
All, this may be pretty easy, but I can't seem to figure something out. I downloaded the sample website, because I wanted to see an example of binding multiple locations to the map. While I see in the sample, that the map is bound to the objectdatasource, what are the names of the fields that I need to provide? Is it latitude, longitude, and zoom only? If so, how do I get certain info into the marker's popup? Thanks in advance.
Jun 25, 2010 at 1:35 PM
Edited Jun 25, 2010 at 7:15 PM

Okay, I think I've gotten really close to it.  I've set up my objectdatasource and I know that it's working and serving description, address, latitude and longitude.

However, markers do not display.  when I add latitude and longitude to the control, a map shows up, but still no markers.  What am I missing? Here is my code:

<artem:googlemap ID="GoogleMap1" cssclass="googlemap" runat="server"  Zoom="4"
        EnableScrollWheelZoom="false" DataSourceID="_odsMarkers" DataAddressField="address" DataTextField="description"  
        ZoomPanType="Large3D" datalatitudefield="latitude" datalongitudefield="longitude" />

<asp:objectdatasource runat="server" id="_odsMarkers"
        oldvaluesparameterformatstring="original_{0}"
        selectmethod="select_StationsByProjectID" typename="BLL_Stations">
        <selectparameters>
            <asp:querystringparameter name="projectid" querystringfield="project"
                type="Int32" />
        </selectparameters>
    </asp:objectdatasource>

When I bind the above datasource to a gridview, I get the data.  But nothing happens for the map :(

 

Jul 6, 2010 at 4:42 PM
Edited Jul 28, 2010 at 6:57 PM
I guess no one else is having this problem? I'll probably have to try another route. However, if someone comes up with a solution in the future, please let me know; I really do think it looks like a neat control.
Jul 28, 2010 at 6:57 PM
I think the problem is that my datapoints are not being returned as a double. Any tips on how I can convert them? Sorry, my VB is weak (C# is even weaker).
Aug 2, 2010 at 3:00 PM
Edited Aug 2, 2010 at 3:14 PM

I haven't gotten much feedback on this (didn't get any actually, but I kept plugging away at it. I was able to get one point to display on the map when I used it as part of a repeater. My code follows:

 

++++++++++++++++++ // in the .ASPX

<asp:repeater id="rptSampleDetail" runat="server" datasourceid="odsSampleDetail"> 
<itemtemplate> 

<%#Eval("taxon")%>Taxonomic Serial Number: <%#Eval("tsn")%>

<asp:literal id="litCoordinates" runat="server" visible="false" /> <artem:googlemap ID="Gmap1" cssclass="googlemap"
 runat="server" Zoom="5" EnableScrollWheelZoom="false" 
 enablegooglemapstate="true" enabledoubleclickzoom="true">
 <markers>
 <artem:googlemarker clickable="true">
   <infowindowtemplate><%= strMapMarkerInfo%></infowindowtemplate>
 </artem:googlemarker>
</markers>
</artem:googlemap> 
</itemtemplate>
</asp:repeater>

++++++++++++++++++ // Codebehind in repeater's itemdatabound

'Check for Latitude & Longitude Dim iCoordinates As ListItemType = e.Item.ItemType 
Dim litCoordinates As Literal 
Select Case iCoordinates 
   Case ListItemType.AlternatingItem, ListItemType.Item 
   litCoordinates = CType(e.Item.FindControl("litCoordinates"), Literal) 
   Dim Gmap1 As Artem.Web.UI.Controls.GoogleMap = _ TryCast(e.Item.FindControl("Gmap1"), Artem.Web.UI.Controls.GoogleMap) 
  
   If String.IsNullOrEmpty(e.Item.DataItem("latitude").ToString) Then 
     litCoordinates.Visible = "False" 
     Gmap1.Visible = False
   Else 
     litCoordinates.Text = "Sample Collection Coordinates: Latitude (" 
     litCoordinates.Text &= e.Item.DataItem("latitude") & "); Longitude (" & _ 
              e.Item.DataItem("longitude") & ") " 
     litCoordinates.Visible = "False" 
     strMapMarkerInfo = "This sample was collected at: <br />"
     strMapMarkerInfo &= "Latitude: " & e.Item.DataItem("latitude") & "<br />"
     strMapMarkerInfo &= "Longitude: " & e.Item.DataItem("longitude") 
Gmap1.Latitude = e.Item.DataItem("latitude")
     Gmap1.ToolTip = "This sample was collected as part of " & e.Item.DataItem("studyname") 
Gmap1.Longitude = e.Item.DataItem("longitude")
Gmap1.Markers.Item(0).Longitude = e.Item.DataItem("longitude")
Gmap1.Markers.Item(0).Latitude = e.Item.DataItem("latitude")
   End If 
End Select 

+++++++++++++++++

I'm still having problems loading a map with more than one marker. Help please. Mozes

Coordinator
Aug 2, 2010 at 6:51 PM
Edited Aug 2, 2010 at 6:53 PM

Hi,

Did you had a look at the DataBinding sample page in Sample WebSite.
You can see it online at http://googlemap.artembg.com/map/DataBinding.aspx, as well.

Regards

Aug 2, 2010 at 7:02 PM
Edited Aug 2, 2010 at 7:05 PM

Hi Velio,

First, thanks for responding. Yes I have looked at the code, but for some reason I've got to be missing something.  You can see what my page looks like here. I added the grid below to see the data.  I know data is being returned, but not sure what I'm doing wrong.

What I have now follows:

<artem:googlemap ID="GoogleMap1" cssclass="googlemap" 
     runat="server"  Zoom="5"       EnableScrollWheelZoom="false" 
     enabledoubleclickzoom="true" DataSourceID="odsMarkers"    
     DataAddressField="address" DataTextField="description" 
     zoomPanType="Large3D" enablemarkermanager="false" 
     showmaptypecontrol="false" Latitude="42.1229" 
     Longitude="24.7879">
 </artem:googlemap>

<asp:objectdatasource runat="server" id="odsMarkers"
        oldvaluesparameterformatstring="original_{0}" 
        selectmethod="select_StationsByProjectID" typename="BLL_Stations">
        <selectparameters>
            <asp:querystringparameter name="projectid" querystringfield="project" 
                type="Int32" />
        </selectparameters>
    </asp:objectdatasource>

Should I have datalatitudefield and datalongitudefield in there?  I tried that but no map displayed until I placed the above random coordinates.  Any guidance will be much appreciated.

Thanks.



Aug 12, 2010 at 3:32 PM

I'm not exactly sure what changed, but it works now. I'm loading the latitude and longitude on page load with the average of all the coordinates so I can get the map centered. 

<artem:googlemap ID="GoogleMap1" cssclass="googlemap" runat="server" Zoom="8" EnableScrollWheelZoom="false" enabledoubleclickzoom="true" DataSourceID="odsMarkers" DataAddressField="address" DataTextField="description" zoomPanType="Large3D" enablemarkermanager="false" showmaptypecontrol="false" datalatitudefield="latitude" datalongitudefield="longitude" />