Please solve my problem. I am tired to pass SQL Server database value in Google Map marker Array in JavaScript Mvc. I am Run the code generate error "marker.length". In this code i will be showing Google Map Marker Cluster. I hope any one can help me. Thanks in Advance..
View
- @{
- ViewBag.Title = "Home Page";
- }
- class="divdisplay">
- >Marker
"dvMap" style="width: 900px; height: 500px">
- public class Crud_class
- {
- public string b_latlng1 { get; set; }
- public string b_latlng2 { get; set; }
- }
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Data;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Web;
- namespace sql_cluster.Models
- {
- public class db
- {
- public List
GetAllRoutes(DateTime dt, string city) - {
- string strConnection = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
- List
lstRoutes = new List (); - using (SqlConnection con = new SqlConnection(strConnection))
- {
- string sql = "select b_latlng from map_table where t_date='" + dt + "' and city='" + city + "'";
- SqlCommand cmd = new SqlCommand(sql, con);
- con.Open();
- SqlDataReader reader = cmd.ExecuteReader();
- Crud_class route = null;
- while (reader.Read())
- {
- route = new Crud_class();
- //route.id = Convert.ToInt32(reader["id"]);
- route.b_latlng1 = (reader["b_latlng"].ToString().Split(',')[0]);
- route.b_latlng2 = (reader["b_latlng"].ToString().Split(',')[1]);
- //route.LatLngTo = reader["b_latlng"].ToString();
- lstRoutes.Add(route);
- }
- }
- return lstRoutes;
- }
- }
- }
- using sql_cluster.Models;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace sql_cluster.Controllers
- {
- public class HomeController : Controller
- {
- public ActionResult Index()
- {
- return View();
- }
- public JsonResult dates(DateTime dt,string city)
- {
- List
lst = new db().GetAllRoutes(dt,city); - return Json(lst, JsonRequestBehavior.AllowGet);
- }
- }
- }
Replies
Know the answer? Post it — somebody with the same question will find it here.