@Html.EJS().Maps("maps").Layers(m =>
{
m.GeometryType(GeometryType.Normal).MarkerSettings(ms =>
{
ms.Visible(true).DataSource(ViewBag.markerData).Add();
}).ShapeData(ViewBag.mapsData).Add();
}).Render()
busSheetData.json:
{ "type": "FeatureCollection", "features": [
{ "type": "Feature", "geometry": { "type": "MultiPolygon", "coordinates": [[[[0, 0], [0, 20], [20, 20], [20, 0], [0, 0]]], [[[0, 22], [0, 27], [20, 27], [20, 22], [0, 22]]]] }, "properties": { "seatno": 19, "fill": "gray" } },
. . .
. . . Add more data’s
] }
MarkerData:
List<MarkerData> data = new List<MarkerData>
{
new MarkerData { latitude= 94, longitude= 0, name= "Bottom left corner" },
. . .
. . . Add more data’s
};
ViewBag.markerData = data; |
@Html.EJS().Maps("maps").Loaded("loaded").Render()
var loaded = function (args) {
var parentSvg = document.getElementById(args.maps.element.id + '_svg');
if (!(parentSvg.firstChild).querySelector('image')) {
var imgElement = document.createElementNS(svgNS, 'image');
//Other configurations
parentSvg.insertBefore(imgElement, parentSvg.firstChild);
}
setTimeout(function () {
var BorderEle = document.getElementById(args.maps.element.id + '_MapBorder');
BorderEle.setAttribute('fill', 'transparent');
}, 100)
} |
@Html.EJS().Maps("maps").Layers(m =>{
m.MarkerSettings( ms => {
ms.TooltipSettings(ts => ts.Template("#template")).Add();
})
}).Render()
|
Controller.cs
List<MarkerData> data = new List<MarkerData>
{
new MarkerData { latitude= 94, longitude= 0, value = 900 },
new MarkerData { latitude=47, longitude=20, value= 2200 },
new MarkerData { latitude= 20, longitude= 20, value= 3000 }
};
ViewBag.markerData = data;
.cshtml:
@Html.EJS().Maps("maps").MarkerRendering("markerRendering").Layers(m =>
{
m.GeometryType(GeometryType.Normal).MarkerSettings(ms => {
ms.Visible(true).Shape(MarkerType.Circle).Height(15).Width(15).TooltipSettings(ts => ts.Visible(true).ValuePath("value")).DataSource(ViewBag.markerData).Add();
}).ShapeData(ViewBag.mapsData).Add();
}
).MapsArea(ma =>ma.Background("transparent")).Render()
var markerRendering = function (args) {
if (args.data.value > 1000) {
args.fill = 'red';
} else {
args.fill = 'green';
}
} |
<div id="maps" stlye="display: block">
@Html.EJS().Maps("maps").Loaded("loaded").MarkerClick("markerClick").Render()
</div>
var markerClick = function (args) {
alert("Marker clicked");
} |