ThinkGeo.com    |     Documentation    |     Premium Support

Marker Not show on .shp file

Dear Sir,



We want show marker on map canvas according to lat. long.

we are apply this process as given below.

-------------------------------------------------------------------------------

winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
                winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
                ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(path);
                worldLayer.Open();
                worldLayer.Name = add_node_name;
                worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;

layerOverlay.Layers.Add("wordlayer", worldLayer);
                winformsMap1.Overlays.Add(layerOverlay); 
                worldLayer.Close();

winformsMap1.Refresh();










public void add_marker(double lat_data, double long_data)
        {  
          Marker marker = new Marker(lat_data,long_data);
          marker.Image = Properties.Resources.China;
          marker.Width = 20;
          marker.Height = 34;
          marker.YOffset = -17;
          SimpleMarkerOverlay markerOverlay = new SimpleMarkerOverlay();
          markerOverlay.Markers.Add(marker);
          winformsMap1.Overlays.Add(markerOverlay);
          winformsMap1.Refresh();  
        }

-------------------------------------------------------------------------------

Please give me solution.



Regards



Harish Upadhyay

           
 

Hi Harish,


I think that the “MapControl” property isn't specified on "SimpleMarkerOverlay" instances as following statement:


markerOverlay.MapControl = winformsMap1;



Thanks,

Don



Dear Sir, 



We are try already this condition this is not working 



as  

------------------- 

public void add_marker(double lat_data, double long_data) 

{   

Marker marker = new Marker(lat_data,long_data); 

marker.Image = Properties.Resources.China; 

marker.Width = 20; 

marker.Height = 34; 

marker.YOffset = -17; 

SimpleMarkerOverlay markerOverlay = new SimpleMarkerOverlay(); 

markerOverlay.MapControl = winformsMap1; 

markerOverlay.Markers.Add(marker); 

winformsMap1.Overlays.Add(markerOverlay); 

winformsMap1.Refresh();   







--------------- 



Regards 



Harish Upadhyay

Dear Sir, 



We are try already this condition this is not working 

as 

------------------- 

public void add_marker(double lat_data, double long_data) 



Marker marker = new Marker(lat_data,long_data); 

marker.Image = Properties.Resources.China; 

marker.Width = 20; 

marker.Height = 34; 

marker.YOffset = -17; 

SimpleMarkerOverlay markerOverlay = new SimpleMarkerOverlay(); 

markerOverlay.MapControl = winformsMap1; 

markerOverlay.Markers.Add(marker); 

winformsMap1.Overlays.Add(markerOverlay); 

winformsMap1.Refresh(); 







--------------- 



Regards 



Harish Upadhyay

Hi Harish, 
  
 As below is how we tested it works. 
  
 Please open your desktop HowDoISamples project and find AddSimpleMarkers file, then put the code as below in it: 
  
  
[5:49:31 PM] Casper Lee: using System;
using System.Windows.Forms;
using ThinkGeo.MapSuite.Core;
using ThinkGeo.MapSuite.DesktopEdition;

namespace CSharpWinformsSamples
{
    public partial class AddSimpleMarkers : UserControl
    {
        public AddSimpleMarkers()
        {
            InitializeComponent();
        }

        private void Form_Load(object sender, EventArgs e)
        {
            winformsMap1.MapClick += new EventHandler<MapClickWinformsMapEventArgs>(winformsMap1_MapClick);
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
            winformsMap1.CurrentExtent = new RectangleShape(-155.733, 95.60, 104.42, -81.9);

            WorldMapKitWmsDesktopOverlay worldMapKitOverlay = new WorldMapKitWmsDesktopOverlay();
            winformsMap1.Overlays.Add(worldMapKitOverlay);

            //winformsMap1.Overlays.Add("MarkerOverlay", markerOverlay);

            winformsMap1.Refresh();
        }

        private void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e)
        {
            SimpleMarkerOverlay markerOverlay = new SimpleMarkerOverlay();
            markerOverlay.MapControl = winformsMap1;

            Marker marker = new Marker(e.WorldLocation);
            marker.Image = Properties.Resources.AQUA;
            marker.Width = 20;
            marker.Height = 34;
            marker.YOffset = -17;

            markerOverlay.Markers.Add(marker);
            winformsMap1.Overlays.Add(markerOverlay);

            winformsMap1.Refresh();
        }

        #region Component Designer generated code

        private System.ComponentModel.IContainer components = null;
        private GroupBox gbxDescrition;
        private WinformsMap winformsMap1;
        private Label label1;

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.gbxDescrition = new System.Windows.Forms.GroupBox();
            this.label1 = new System.Windows.Forms.Label();
            this.winformsMap1 = new ThinkGeo.MapSuite.DesktopEdition.WinformsMap();
            this.gbxDescrition.SuspendLayout();
            this.SuspendLayout();
            // 
            // gbxDescrition
            // 
            this.gbxDescrition.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.gbxDescrition.Controls.Add(this.label1);
            this.gbxDescrition.Location = new System.Drawing.Point(480, -1);
            this.gbxDescrition.Name = "gbxDescrition";
            this.gbxDescrition.Size = new System.Drawing.Size(257, 55);
            this.gbxDescrition.TabIndex = 4;
            this.gbxDescrition.TabStop = false;
            this.gbxDescrition.Text = "Description";
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(7, 20);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(251, 26);
            this.label1.TabIndex = 0;
            this.label1.Text = "This sample shows how to add markers by click\r\n event on the map.";
            // 
            // winformsMap1
            // 
            this.winformsMap1.BackColor = System.Drawing.Color.White;
            this.winformsMap1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.winformsMap1.Location = new System.Drawing.Point(0, 0);
            this.winformsMap1.Name = "winformsMap1";
            this.winformsMap1.Size = new System.Drawing.Size(740, 528);
            this.winformsMap1.TabIndex = 5;
            this.winformsMap1.Text = "winformsMap1";
            // 
            // AddMyOwnCustomDataToAFeatureLayer
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Controls.Add(this.gbxDescrition);
            this.Controls.Add(this.winformsMap1);
            this.Name = "AddMyOwnCustomDataToAFeatureLayer";
            this.Size = new System.Drawing.Size(740, 528);
            this.Load += new System.EventHandler(this.Form_Load);
            this.gbxDescrition.ResumeLayout(false);
            this.gbxDescrition.PerformLayout();
            this.ResumeLayout(false);

        }

        #endregion
    }
}
 
  
 Please let us know whether it works for you. 
  
 Regards, 
  
 Don

Hi Harish,  



Attached file is what we are using for test.  



Please open your desktop HowDoISamples project and find AddSimpleMarkers file, then put the code in it.

<mapclickwinformsmapeventargs>

Please let us know whether it works for you.  



Regards,  



Don</mapclickwinformsmapeventargs>

11905.txt (4.92 KB)

Dear Sir,



This is working properly.



Thank & Regards



Harish Upadhyay

Dear Sir,

I am inserting  India Lat. Long. Value but the marker
show outside of the Exact Location So please give me solution.


Some code give below 


public void add_marker_layer()


        {


           
try


           
{


               
SimpleMarkerOverlay markerOverlay = new SimpleMarkerOverlay();


         
      markerOverlay.MapControl = winformsMap1;


               
winformsMap1.Overlays.Add("MarkerOverlay",
markerOverlay);


               
winformsMap1.Refresh();


           
}


           
catch (Exception
ex)


           
{


               
MessageBox.Show(ex.Message, "Error");


           
}


 


        }


        Marker marker;


        public void
add_marker()


        {


           
try


           
{


 


               
SimpleMarkerOverlay markerOverlay = (SimpleMarkerOverlay)winformsMap1.Overlays["MarkerOverlay"]; 


                marker
= new Marker(
74.840478,30.421914);


               
marker.Image = Properties.Resources.AQUA;


               
marker.Width = 20;


               
marker.Height = 34;


               
marker.YOffset = -17;


               
markerOverlay.Markers.Add(marker);


               
winformsMap1.Refresh();


           
}


           
catch (Exception
ex)


           
{


               
MessageBox.Show(ex.Message, "Error");


           
}


        }


 


Regards


Harish
Upadhyay



Hi Harish,  
  
 Could you please upload a screen capture about your issue? 
  
 It looks your code works well. 
  
 Does that because your baselayer is based on different projection? It looks your marker is based on WGS84(4326). 
  
 Regards, 
  
 Don

Dear Sir,



This is working properly.



Thanks & Regards



Harish Upadhyay 

Hi Harish, 
  
 I am glad to hear that works for you. 
  
 Regards, 
  
 Don