I'm implementing a Universal Windows Platform (UWP) app, and I m using the Carto Map Mobile SDK (UWP). However, I don't know how to add a .png image as a Map Marker programmatically. Here is my code:
/// Preparation - create layer and datasource
// projection will be needed later
Projection projection = map.Options.BaseProjection;
// Initialize an local data source - a bucket for your objects created in code
LocalVectorDataSource datasource = new LocalVectorDataSource(projection);
// Initialize a vector layer with the previous data source
VectorLayer layer = new VectorLayer(datasource);
// Add layer to map
map.Layers.Add(layer);
/// Now we real adding objects
// Create marker style
MarkerStyleBuilder builder = new MarkerStyleBuilder();
builder.Size = 20;
BinaryData iconBytes = AssetUtils.LoadAsset("Z:/FolderName/ProjectName/Assets/markers_mdpi/mapmarker.png");
byte[] bytearray = iconBytes.GetData();
int size = Marshal.SizeOf(bytearray[0]) * bytearray.Length;
IntPtr pnt = Marshal.AllocHGlobal(size);
builder.Bitmap = new Bitmap(pnt, true);
MarkerStyle style = null;
style = builder.BuildStyle();
// Create a marker with the style we defined previously and add it to the source
Marker marker = new Marker(position, style);
datasource.Add(marker);
The Carto Map official technical document didn't help at all, and here is the screenshot . However, when I installed the official SDK.UWP via the Nuget, there aren't any relevant functions that mentioned in the document in the library.
Can anyone help me solve this problem?
Otherwise, it is meaningless for me to create this UWP app further.