ThinkGeo.com    |     Documentation    |     Premium Support

Avoid Map Refresh on Click

 Hello,


I'm testing the Web Edition and I'm having some troubles everytime I click on the map. Everytime that I click somewhere on the map, the whole page is refreshed without any reasons... I have nothing in the method "OnClick" however.


By the way, I'm using the GoogleMap layer


 


Here is my code.


 


 



The control:




<cc1:Map ID="MyMap" runat="server" Height="680px" Width="1600px" OnClick="Map_Click">



The declaration of my map




protected void Page_Load(object sender, EventArgs e)
 try
            {
                if (!IsPostBack)
                {
                    MyMap.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
                    MyMap.CurrentExtent = new RectangleShape(-125, 72, 50, -46);
                    MyMap.MapUnit = GeographyUnit.Meter;

                //initialization
                    var currentMap = new Map();
                                           
                    MyMap.MapTools.OverlaySwitcher.Enabled = true;
                    MyMap.MapTools.AnimationPanMapTool.Enabled = true;
                    //Map1.MapTools.TouchMapTool.Enabled = true;        
                    MyMap.MapTools.MouseCoordinate.Enabled = true;

                    MyMap.CustomOverlays.Add(currentMap.GoogleOverlay);
                    MyMap.CustomOverlays.Add(currentMap.StaticOverlay);
                    //Map1.CustomOverlays.Add(dynamicOverlay);   
                }
           
                initialize();
            }
            catch (Exception ex)
            {
              
            }
        }

 protected void Map_Click(object sender, MapClickedEventArgs e)  
        {}




The creation of the "layers" + "overlays", Class Map.cs




 public Map()
        {
            InitGoogleOverlay();
            InitStaticOverlay();
        }

 
        private void InitGoogleOverlay()
        {
            var googleOverlay = new GoogleOverlay("Google Map");
            googleOverlay.GoogleMapType = GoogleMapType.Normal;

            GoogleOverlay = googleOverlay;
        }

 private void InitStaticOverlay()
        {
            LayerOverlay staticOverlay = new LayerOverlay(STAT_OVERLAY, true, TileType.SingleTile);
            //LayerOverlay staticOverlay = new LayerOverlay(STAT_OVERLAY);
            staticOverlay.Layers.Add(WORLD_LAYER, WorldLayer());
            staticOverlay.IsBaseOverlay = false;

            StaticOverlay = staticOverlay;
        }

  private ShapeFileFeatureLayer WorldLayer()
        {
            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(COUNTRY_FILE_PATH);

            AreaStyle areaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green));
            worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(areaStyle);

            //use the projection to keep the shape file working with google map
            Proj4Projection proj4 = new Proj4Projection();
            proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
            proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();

            worldLayer.FeatureSource.Projection = proj4;

 worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            return worldLayer;




Does anybody have already got this issue ??

Hello Patrick, 
  
 The problem is you are using: 
  
 <cc1:Map ID="MyMap" runat="server" Height="680px" Width="1600px" OnClick="Map_Click">

And this code will cause the client side request the server side, because "runat=server", you can using ajax to avoid this.

Regards,

 Gary