public ActionResult GetClusterMapData() { var db = new ApplicationDbContext(); var measureService = new MeasureService(db); var listMarker = new List <Marker>(); db.ProductionUnits.Include(p => p.owner.preferedMoment).ToList().ForEach(p => { var phone = p.owner.phoneNumber == null ? "00 33 3 67 37 00 56" : p.owner.phoneNumber; var contactMail = p.owner.contactMail == null ? "*****@*****.**" : p.owner.contactMail; listMarker.Add(new Marker(p.locationLatitude, p.locationLongitude, String.Format(@"Click for view details")) { shape = "redMarker" }); }); var map = new Models.ClusterMap() { Name = "map", CenterLatitude = 44.0235561, CenterLongitude = 0.3640063, Zoom = 4, TileUrlTemplate = "http://#= subdomain #.tile.openstreetmap.org/#= zoom #/#= x #/#= y #.png", TileSubdomains = new string[] { "a", "b", "c" }, TileAttribution = "© <a href='http://osm.org/copyright'>OpenStreetMap contributors</a>" }; var result = new GeoClusterMapData { type = "FeatureCollection" }; var list = new List <GeoFeature>(); foreach (var marker in listMarker) { var feature = new GeoFeature { type = "Feature" }; feature.properties = new GeoProperties { scalerank = 2, name = marker.name, long_x = marker.latlng[0], lat_y = marker.latlng[1] }; feature.geometry = new Geometry { type = "Point", coordinates = new double[] { marker.latlng[1], marker.latlng[0] } }; list.Add(feature); } result.features = list.ToArray(); map.ClusterData = result; var data = new JavaScriptSerializer().Serialize(map); return(Json(new { data }, JsonRequestBehavior.AllowGet)); }
public ActionResult GetClusterMapData() { var db = new ApplicationDbContext(); var measureService = new MeasureService(db); var listMarker = new List <Marker>(); db.ProductionUnits.ToList().ForEach(p => listMarker.Add(new Marker(p.locationLatitude, p.locationLongitude, String.Format("{0} </br> start since {1}", p.info, p.startDate.ToShortDateString())) { shape = "redMarker" })); var map = new Models.ClusterMap() { Name = "map", CenterLatitude = 44.0235561, CenterLongitude = -10.3640063, Zoom = 4, TileUrlTemplate = "http://#= subdomain #.tile.openstreetmap.org/#= zoom #/#= x #/#= y #.png", TileSubdomains = new string[] { "a", "b", "c" }, TileAttribution = "© <a href='http://osm.org/copyright'>OpenStreetMap contributors</a>" }; var result = new GeoClusterMapData { type = "FeatureCollection" }; var list = new List <GeoFeature>(); foreach (var marker in listMarker) { var feature = new GeoFeature { type = "Feature" }; feature.properties = new GeoProperties { scalerank = 2, name = marker.name, long_x = marker.latlng[0], lat_y = marker.latlng[1] }; feature.geometry = new Geometry { type = "Point", coordinates = new double[] { marker.latlng[1], marker.latlng[0] } }; list.Add(feature); } result.features = list.ToArray(); map.ClusterData = result; var data = new JavaScriptSerializer().Serialize(map); return(Json(new { data }, JsonRequestBehavior.AllowGet)); }