image from database on marker infowindow

Jul 4, 2009 at 5:32 PM

 

hi

first of all really thanks for this great component

i just started a project with google map component and i am very happy and impressed with it

now i have a question

is it possible to create markers dynamically from database and populate each infowindow with field from database including images

 

here my code :

 

 if (!Page.IsPostBack)
        {
            SqlConnection myConnection;
            SqlCommand myCommand;
            SqlDataReader myDataReader;

            myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString);

            myConnection.Open();


            //prepare sql statements
            myCommand = new SqlCommand("SELECT VO.ID_VOITURE,  VO.VO_NOM, VO.VO_CONDUCTEUR, VO.VO_TELEPHONE, VO.VO_MATRICULE, POS_LONGITUDE,  POS_LATITUDE  FROM POSITIONS  LEFT JOIN VOITURES VO ON ID_VOITURE = POS_ID_VOITURE", myConnection);
            myDataReader = myCommand.ExecuteReader();
          
            while (myDataReader.Read())
            {
                GoogleMarker CameraMarker = new GoogleMarker();
                GoogleSize CamImageSize = new GoogleSize();
                //   CameraMarker.ImageUrl = "~/images/clio.png";

                CamImageSize.Height = 25;
                CamImageSize.Width = 25;
               
          /*    CameraMarker.AutoPan = true;*/

                

                CameraMarker.Longitude = float.Parse(myDataReader["POS_LONGITUDE"].ToString());
                CameraMarker.Latitude = float.Parse(myDataReader["POS_LATITUDE"].ToString());
                //CameraMarker.Text = "Description : " + camDescription + "</br>Cam Image :<a href='" + camImage + "' target=_blank>Click Here</a>";
                //CameraMarker.ImageUrl = "images/scenic.png";
                CameraMarker.IconSize = CamImageSize;
//              CameraMarker.InfoContent.TemplateControl.
          //    Response.Write("test <br/>"); 
                CameraMarker.Text = "<b>Voiture</b><br/>" + myDataReader["VO_NOM"].ToString() + "<br/>" +
                    "<b>Matricule</b><br/>" + myDataReader["VO_MATRICULE"].ToString() + "<br/>" +
                    "<b>Conducteur</b><br/>" + myDataReader["VO_CONDUCTEUR"].ToString() + "<br/>" +
                    "<b>Téléphone</b><br/>" + myDataReader["VO_TELEPHONE"].ToString() ;
                GoogleMap1.Markers.Add(CameraMarker);
            }

            myDataReader.Close();
            myConnection.Close();

 

 

but i want some images in the right from the database or not

what is the best mehtod to do something like this 

 

thanks and good day

Jul 6, 2009 at 9:40 AM

Hi, I had to do something similar and my approach has been to create a html "page" to pass to marker.Text as you are already doing for Voiture, Matricule etc:

CameraMarker.Text = "<b>Voiture</b><br/>" + myDataReader["VO_NOM"].ToString() + "<br/>" +
                    "<b>Matricule</b><br/>" + myDataReader["VO_MATRICULE"].ToString() + "<br/>" +
                    "<b>Conducteur</b><br/>" + myDataReader["VO_CONDUCTEUR"].ToString() + "<br/>" +
                    "<b>Téléphone</b><br/>" + myDataReader["VO_TELEPHONE"].ToString()  + 
		"<img src='" + myDataReader["VO_IMAGE"].ToString() + "' border='0' width='100px' height='75px'/>";

VO_IMAGE is juts my guess obviously :)

 

Coordinator
Jul 7, 2009 at 12:41 PM

Hi

Why not try to use data binding features of the control.
Take a look at the http://googlemap.artembg.com/map/DataBinding.aspx

The source of that page could be found in SampleWebSite under project files.

Regards

Jul 7, 2009 at 3:04 PM

thanks guys 

the databinding way can be a solution but i have to take a closer look on it

in the meaning time i have a question

 is it possible to get a databounded map with markers and refresh markers at a time interval by refreshing it's datasource

but without refreshing all the map or the page just like in the clientupdate example (that i admit that dos'ent understood it)

so we can view "moving markers" on the map depending on the database (server side) table changes

 

thanks and good day

 

Coordinator
Jul 8, 2009 at 6:53 AM

Hi,

As I mantioned earlier, I started working on AJAX Control Extenders for GoogleMap control.
For example similar like the AJAX Control Toolkit Extenders - AutoComplete, CascadingDropDown etc.
Using the exteners will be posible you to give a PageMethod or and WebService method where the extender for example to get the markers' list and update the map on client side.
Apart of the UpdatePanel, that's for me a better and lighter aproach.

Regards

 

Jul 8, 2009 at 5:40 PM

sound great

and release date ? :)

 

good day

Nov 25, 2009 at 12:26 PM

great, can't wait =)