ThinkGeo.com    |     Documentation    |     Premium Support

Maker and contextmenu problem

Good day.
I have question.

I want draw marker and clicked context menu on the map.
My sample code is success draw marker on the map.
but, not working marker click event and don’t view context menu.

please check my code & problems.

Best regards.

— Index.cshtml —
@{ Html.ThinkGeo().Map(Model).Render(); }

— Controller —
ContextMenu menuOn = new ContextMenu(“test”, 180);
ContextMenuItem redirectItem = new ContextMenuItem(“test”);
menuOn.MenuItems.Add(redirectItem);

SimpleMarkerOverlay o = new SimpleMarkerOverlay();
Marker m = new Marker(128, 37);
m.WebImage = new WebImage("/Content/images/bcncar01.png");
m.WebImage.RotationAngle = 30;
m.Id = @“1”;
m.ContextMenu = menuOn;

o.Markers.Add(m);

m = new Marker(129, 38);
m.WebImage = new WebImage("/Content/images/bcncar01.png");
m.WebImage.RotationAngle = 270;
m.Id = @“2”;
m.ContextMenu = menuOn;
o.Markers.Add(m);

m.ContextMenu = menuOn;

__map.CustomOverlays.Add(o);

Hi Binary,

As below is my test code, you can directly use it replace the files in our HowDoISamples project.

8231.zip (1.2 KB)

And it looks the context menu works well.

Regards,

Don

Thank you for reply.
We are check problem with this source.
finally, we find out cause of problem.
That problem is using ScaleBarAdornmentLayer.

----------------- Existing Source Code -----------------
__map.MapTools.ScaleLine.Enabled = false; // Default scalebar Disable
ScaleBarAdornmentLayer scaleBar = new ScaleBarAdornmentLayer();
scaleBar.Location = AdornmentLocation.LowerLeft;
scaleBar.UnitFamily = UnitSystem.NauticalMile;
__map.AdornmentOverlay.Layers.Add(scaleBar);

But, don’t click marker with this exiting source.

----------------- Channged Source Code -----------------
__map.MapTools.ScaleLine.Enabled = false; // Default scalebar Disable
//ScaleBarAdornmentLayer scaleBar = new ScaleBarAdornmentLayer();
//scaleBar.Location = AdornmentLocation.LowerLeft;
//scaleBar.UnitFamily = UnitSystem.NauticalMile;
//__map.AdornmentOverlay.Layers.Add(scaleBar);

Changed Source code is possible clicke marker.

if should not be used ScaleBarAdornmentLayer with marker?

Please check my mistake.

Hi Binary,

I did quickly modify with the test file in my last reply, it looks with ScaleBar it still works well.

map.MapTools.ScaleLine.Enabled = false;
ScaleBarAdornmentLayer scaleBar = new ScaleBarAdornmentLayer();
scaleBar.Location = AdornmentLocation.LowerLeft;
scaleBar.UnitFamily = UnitSystem.NauticalMile;
map.AdornmentOverlay.Layers.Add(scaleBar);

Please try my test class and let me know whether it can be reproduced there, and please let me know whether I follow the correct way to reproduce that.

  1. Right click on marker, “test” popup correct.
  2. Right click on the other part of map, browser system context menu popup.

My test environment is Win7 X64, Chrome v53.

Regards,

Don

Hi Don.
Thank you for reply.

We are test class with your sample code.

// Index.cshtml
@using ThinkGeo.MapSuite.MvcEdition
@using ThinkGeo.MapSuite.Core
@model ThinkGeo.MapSuite.MvcEdition.Map

<div class="twelve columns" id="main">
    <div id="map">
        @{Html.ThinkGeo().Map(Model).Render();}
    </div>
</div>

// HomeController.cs

public ActionResult Index()
        {
            Map map = new Map("Map1",
            new System.Web.UI.WebControls.Unit(100, System.Web.UI.WebControls.UnitType.Percentage),
            510);
            map.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
            map.CurrentExtent = new RectangleShape(120, 40, 130, 30);
            map.MapUnit = GeographyUnit.DecimalDegree;

            //map.MapTools.ScaleLine.Enabled = false;
            ScaleBarAdornmentLayer scaleBar = new ScaleBarAdornmentLayer();
            scaleBar.Location = AdornmentLocation.LowerLeft;
            scaleBar.UnitFamily = UnitSystem.NauticalMile;
            map.AdornmentOverlay.Layers.Add(scaleBar);

            ContextMenu menuOn = new ContextMenu("test", 180);
            ContextMenuItem redirectItem = new ContextMenuItem("test");
            menuOn.MenuItems.Add(redirectItem);

            SimpleMarkerOverlay o = new SimpleMarkerOverlay();
            Marker m = new Marker(128, 37);
            m.WebImage = new WebImage("/Content/images/test.png");
            m.WebImage.RotationAngle = 30;
            m.Id = @"1";
            m.ContextMenu = menuOn;
            o.Markers.Add(m);

            m = new Marker(129, 38);
            m.WebImage = new WebImage("/Content/images/test.png");
            m.WebImage.RotationAngle = 270;
            m.Id = @"2";
            m.ContextMenu = menuOn;
            o.Markers.Add(m);

            m.ContextMenu = menuOn;

            map.CustomOverlays.Add(o);

            return View(map);
        }

Finally Result…
First Right click on marker, “test” popup.

Second Right click on scalebar&other section.

Environment : Win 8.1 Enterprise x64, Chrome v53.
We are get same result at Internet Explorer v11.

Please check for any problem.
Best regards.

Hi Binary,

The issue has been recreated and our developer are still working on it. A workaround for this, ,please following the steps.

  1. Inspect the html element to found the div contains the adornment layer, “OpenLayers_Control_Attribution_2” for example like below.

  2. Add the style for “OpenLayers_Control_Attribution_2” in the page and make sure that it has the high priority.

    #OpenLayers_Control_Attribution_2{pointer-events: none;}

Thanks,
Peter

Hi Binary,

I’m sorry for late replying, you are correct, this issue is a bug.

We have fixed it now, you can get the latest version 9.0.488.0 mvc edition from product center.

Thanks,