# Creating markers and polygons without using

**URL:** <https://mapwindow.discourse.group/t/creating-markers-and-polygons-without-using/674>\
**Category:** MapWinGIS\
**Created:** [July 27, 2020, 4:15pm UTC](https://mapwindow.discourse.group/t/creating-markers-and-polygons-without-using/674 "2020-07-27T16:15:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZeroByter](https://avatars.discourse-cdn.com/v4/letter/z/ccd318/32.png) [@ZeroByter](https://mapwindow.discourse.group/u/ZeroByter)\
**Post date:** [July 27, 2020, 4:15pm UTC](https://mapwindow.discourse.group/t/creating-markers-and-polygons-without-using/674/1 "2020-07-27T16:15:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jerryfaust](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/jerryfaust/32/378_2.png) [@jerryfaust](https://mapwindow.discourse.group/u/jerryfaust)\
**Post date:** [July 27, 2020, 6:03pm UTC](https://mapwindow.discourse.group/t/creating-markers-and-polygons-without-using/674/2 "2020-07-27T18:03:23Z")

</div>

Hello @ZeroByter

You might consider using the [Drawing layers](https://www.mapwindow.org/documentation/mapwingis4.9/group __map__ drawing__layers.html). However, they have their limitations, particularly regarding custom rendering.

I would recommend using a Shapefile, but setting [Volatile property](https://www.mapwindow.org/documentation/mapwingis4.9/group __shapefile__ editing.html#ga6b85eba2980a1bcb771c564c4edd6586) = true. It is then drawn along with the drawing layers, without having to redraw all data layers, using [Redraw2](https://www.mapwindow.org/documentation/mapwingis4.9/class_ax_map.html#aca3c89d67a51f258a29a88d173dff12b) with [tkRedrawType.RedrawSkipDataLayers](https://www.mapwindow.org/documentation/mapwingis4.9/_enumerations_8cs.html#a466377e9561be0ab96e04cc2b139cf38).

Hope that helps.

Regards,  
Jerry.

---

<div class="post-metadata">

**Author:** ![ZeroByter](https://avatars.discourse-cdn.com/v4/letter/z/ccd318/32.png) [@ZeroByter](https://mapwindow.discourse.group/u/ZeroByter)\
**Post date:** [July 27, 2020, 6:04pm UTC](https://mapwindow.discourse.group/t/creating-markers-and-polygons-without-using/674/3 "2020-07-27T18:04:00Z")

</div>

I’ll look into it, thanks!

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [August 25, 2020, 10:04pm UTC](https://mapwindow.discourse.group/t/creating-markers-and-polygons-without-using/674/4 "2020-08-25T22:04:02Z")

</div>

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