Advertisement
Guest User

Untitled

a guest
Oct 13th, 2017
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. public JsonResult GetData()
  2. {
  3.  
  4. List<Park> stations = new List<Park>();
  5.  
  6. stations.Add(new Park()
  7. {
  8. Id = 2,
  9. GeoLat = 37.608644,
  10. GeoLong = 55.75226,
  11. Weight = 12
  12. });
  13.  
  14. stations.Add(new Park()
  15. {
  16. Id = 3,
  17. GeoLat = 30.5807913,
  18. GeoLong = 50.493239,
  19.  
  20. Weight = 12
  21. });
  22.  
  23. return Json(stations.ToArray(), JsonRequestBehavior.AllowGet);
  24. }
  25.  
  26. function getPoints() {
  27.  
  28. $.getJSON('@Url.Action("GetData", "Home")',
  29. function (data) {
  30. var marker;
  31. // Проходим по всем данным и устанавливаем для них маркеры
  32. $.each(data,
  33. function(i, item) {
  34. marker = [
  35. {
  36. 'location': new google.maps.LatLng(item.GeoLong, item.GeoLat),
  37. 'map': map,
  38. 'weight': item.Weight
  39. }
  40. ];
  41. });
  42.  
  43.  
  44.  
  45. var pointArray = new google.maps.MVCArray(marker);
  46. console.log(pointArray);
  47. heatmap = new google.maps.visualization.HeatmapLayer({
  48. data: pointArray
  49. });
  50. heatmap.setMap(map);
  51.  
  52.  
  53. });
  54. };
  55.  
  56. function initMap() {
  57. map = new google.maps.Map(document.getElementById('map'),
  58. {
  59. zoom: 13,
  60. center: { lat: 55.752622, lng: 37.617567 },
  61. mapTypeId: 'satellite'
  62. });
  63. getPoints();
  64. }
  65.  
  66. return Json(stations.ToArray(), JsonRequestBehavior.AllowGet);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement