Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public JsonResult GetData()
- {
- List<Park> stations = new List<Park>();
- stations.Add(new Park()
- {
- Id = 2,
- GeoLat = 37.608644,
- GeoLong = 55.75226,
- Weight = 12
- });
- stations.Add(new Park()
- {
- Id = 3,
- GeoLat = 30.5807913,
- GeoLong = 50.493239,
- Weight = 12
- });
- return Json(stations.ToArray(), JsonRequestBehavior.AllowGet);
- }
- function getPoints() {
- $.getJSON('@Url.Action("GetData", "Home")',
- function (data) {
- var marker;
- // Проходим по всем данным и устанавливаем для них маркеры
- $.each(data,
- function(i, item) {
- marker = [
- {
- 'location': new google.maps.LatLng(item.GeoLong, item.GeoLat),
- 'map': map,
- 'weight': item.Weight
- }
- ];
- });
- var pointArray = new google.maps.MVCArray(marker);
- console.log(pointArray);
- heatmap = new google.maps.visualization.HeatmapLayer({
- data: pointArray
- });
- heatmap.setMap(map);
- });
- };
- function initMap() {
- map = new google.maps.Map(document.getElementById('map'),
- {
- zoom: 13,
- center: { lat: 55.752622, lng: 37.617567 },
- mapTypeId: 'satellite'
- });
- getPoints();
- }
- return Json(stations.ToArray(), JsonRequestBehavior.AllowGet);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement