Creating markers and polygons without using

Hey guys.

I wanted to know if it was possible to create shapes on the map, specifically markers and polygons without creating/opening a shapefile?

My program is going to be run under ‘less than ideal’ conditions as it is and I don’t really see the benefit of using a shapefile to store simple makers and polygons. Plus I want to save on speed, efficiency, and storage space.

I’m going to load my markers and polygons from a JSON file, so I got that covered, I just need to know if it’s possible to use markers/polygons layers without shapefiles?

This is my current code:

using AxMapWinGIS;
using MapWinGIS;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms.Integration;
using System.Windows.Input;
using Point = MapWinGIS.Point;
using Shape = MapWinGIS.Shape;

namespace BlueSky.UserControls
{
	/// <summary>
	/// Interaction logic for Map.xaml
	/// </summary>
	public partial class Map : UserControl
	{
		private WindowsFormsHost formsHost;
		private AxMap map;

		public Map()
		{
			InitializeComponent();
		}

		public AxMap GetMap()
		{
			return map;
		}

		private void UserControl_Loaded(object sender, RoutedEventArgs e)
		{
			formsHost = new WindowsFormsHost();
			map = new AxMap();
			formsHost.Child = map;
			MapGrid.Children.Add(formsHost);

			map.Projection = tkMapProjection.PROJECTION_GOOGLE_MERCATOR;
			map.MapResizeBehavior = tkResizeBehavior.rbModern;
			map.CursorMode = tkCursorMode.cmPan;

			map.Tiles.UseCache[tkCacheType.Disk] = false;
			map.Tiles.DoCaching[tkCacheType.Disk] = false;

			//map.ShapeEditor.StartUnboundShape((MapWinGIS.ShpfileType)5);

			var providers = map.Tiles.Providers;
			var providerid = (int)tkTileProvider.ProviderCustom + 1002;

			providers.Add(providerid, "land", "http://localhost:8991/land/z{zoom}/{y}/{x}.jpg", tkTileProjection.SphericalMercator, 3, 15, "test");

			//MapControlLib.Tiles.ClearCache(tkCacheType.RAM);
			//map.Tiles.ClearCache(tkCacheType.Disk);
			map.Tiles.ProviderId = providerid;

			map.InertiaOnPanning = tkCustomState.csFalse; //inertia is cool but it doesnt work well for some reason (laggy) so i just disable it

			map.SendMouseUp = true;
			map.MouseUpEvent += Map_MouseUpEvent;
		}

		private void Map_MouseUpEvent(object sender, _DMapEvents_MouseUpEvent e)
		{
			if (e.button == 1)          // left button
			{
				Shape shp = new Shape();
				shp.Create(ShpfileType.SHP_POINT);
				Point pnt = new Point();
				double x = 0.0;
				double y = 0.0;
				map.PixelToProj(e.x, e.y, ref x, ref y);
				pnt.x = 32;
				pnt.y = 34;
				Console.WriteLine($"{x},{y}");
				int index = shp.numPoints;
				shp.InsertPoint(pnt, ref index);

				map.AddLayer(shp, true);
				map.Redraw();
			}
		}
	}
}

Forget to mention… the code above does not work and does not show the marker.

Hello @ZeroByter

You might consider using the Drawing layers. However, they have their limitations, particularly regarding custom rendering.

I would recommend using a Shapefile, but setting Volatile property = true. It is then drawn along with the drawing layers, without having to redraw all data layers, using Redraw2 with tkRedrawType.RedrawSkipDataLayers.

Hope that helps.

Regards,
Jerry.

I’ll look into it, thanks!

This topic was automatically closed 29 days after the last reply. New replies are no longer allowed.