My question is, how can I get Leaflet to color each of circleMarkers I am generating/points with a different color, based off the type property of the point?
I've done a bit of research, but all I've seen is coloring points based on manually created dictionary, while my "known list of types" can be expanded at any time, and additional colors have to be added to accommodate new types of points. Also I am quite weak in Javascript and its actual syntax.
I have the list of all unique types before the iteration over data.
I am working in C# MVC if that helps.
My view (presentation layer of the program - generates a HTML page based off its contents) iterates over Model data (basically data which I need to show on the map) which contains latitude, longitude and type properties (more than that, but irrelevant for this), and adds the points to map, drawing them.
Code that generates my points:
{
foreach (var item in Model)
{
<text>var point = L.circleMarker(["@item.Latitude", "@item.Longitude"]).addTo(mymap)
.bindPopup("@item.Type.TypeDesc" + ", " + "@item.Latitude" + ", " + "@item.Longitude" + ", " + "@item.RPT_DT").openPopup(); </text>
}
}
I need each point to be of a color depending on TypeDesc property. List of TypeDesc properties can be easily accessed via a Viewbag.TypeDesc list.