Ich habe Back-End mit Liste, wo ich 2 Plätze habe.Google Heat Map Anzeige nur einen Platz
Hier ist Code auf Back - End.
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);
}
Und ich bekomme es auf Client-Seite wie diese
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);
});
};
und aktualisieren Karte in dieser Methode
function initMap() {
map = new google.maps.Map(document.getElementById('map'),
{
zoom: 13,
center: { lat: 55.752622, lng: 37.617567 },
mapTypeId: 'satellite'
});
getPoints();
}
Aber ich sehe nur einen Ort. Ich verstehe nicht, warum, weil ich Haltepunkt in dieser Zeile
setze ich 2 Plätze zurückgibt.
Wo kann mein Problem sein?
Dankten Hilfe
Ja. Es hilft. Vielen Dank –