Urgent - Handling Map Click event

Hi all,

I have a strange requirement.

I have a small Virtual map appearing on one of my pages. Now on its click I want to open a popup window which will be a bigger version of the small map displayed. For this, I have done following

map = new VEMap('VirtualMap');

try{map.LoadMap(new VELatLong(latitude, longitude), 8 ,'r' ,false);}

catch(err){}

map.AttachEvent('onclick', openVirtualMap);

This functon openVirtualMap opens a new popup window which conatins the larger map.

Now the problem which I am facing is

1. After clicking on the small map, The popup comes up and then the popup suddenly gets minimized. I used

event.cancelBubble = true;

I also tried setting the focus to my popup but no use.

But still the window is getting minimized. I dont want it to get minimized. :(

Please Help.




Answer this question

Urgent - Handling Map Click event

  • Stéphane Beauchemin

    Mukund,

    can you please give us some sample code to reproduce this problem



  • dotHuman

    Here is the sample code.

    1. Copy this code and save it as "map.html"
    2. Then open the page
    3. Click on map

    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script src="http://dev.virtualearth.net/mapcontrol/v4/mapcontrol.js"></script>
    <script>
    var map = null;

    function GetMap()
    {
    map = new VEMap('myMap');
    map.LoadMap(new VELatLong(47.6, -122.33), 10 ,'r' ,false);
    map.AttachEvent('onclick', openVirtualMap);
    }
    function openVirtualMap()
    {
    var mapwindow=window.open('map.html','mapwindow','width=790,height=620,menubar=no,location=no,status=no');

    if(mapwindow && window.focus)
    {
    mapwindow.focus();
    }
    event.cancelBubble = true;
    }
    </script>
    </head>
    <body onload="GetMap();">
    <div id='myMap' style="position:relative; width:400px; height:400px;"></div>
    </body>
    </html>




  • MerryPoppins

    Something is wrong with your browser + windows settings.

  • chakravarthy_b

    I dont know then, since I can't reproduce it. Anyone else getting this problem

  • Darkphibre

    I tested it on 3 different machines with all the three browser. Same result. The problem is still there. Especially with IE.



  • yusufaz

    :) I got the workaround. Sometimes Complex problems has complex Solutions but simple Workaround.

    Just add an Outer Div to the map div and then Attach the onclick event to this new div.

    Try this Code

    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script src="http://dev.virtualearth.net/mapcontrol/v4/mapcontrol.js"></script>
    <script>
    var map = null;

    function GetMap()
    {
    map = new VEMap('myMap');
    map.LoadMap(new VELatLong(47.6, -122.33), 10 ,'r' ,false);
    // map.AttachEvent('onclick', openVirtualMap); Not needed AnyMore
    }
    function openVirtualMap()
    {
    var mapwindow=window.open('map.html','mapwindow','width=790,height=620,menubar=no,location=no,status=no');

    if(mapwindow && window.focus)
    {
    mapwindow.focus();
    }
    event.cancelBubble = true;
    }
    </script>
    </head>
    <body onload="GetMap();">
    <div id="outerdiv" onclick=openVirtualMap();"> <div id='myMap' style="position:relative; width:400px; height:400px;"></div></div>
    </body>
    </html>



  • BSohante

    Did you turn on your security settings to allow activeX to run on your machine locally I had to do that to prevent all those annoying IE popups. Also to make this run under Firefox 2.0 you need to setup the VE differently, look on the VE wiki to find the code on that one. Are you not getting any popup warnings Any warnings in the bottom left corner (like javascript errors)

  • MystMan

    Try this modified code:

    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script src="http://dev.virtualearth.net/mapcontrol/v4/mapcontrol.js"></script>
    <script>
    var map = null;

    function GetMap()
    {
    map = new VEMap('myMap');
    map.LoadMap(new VELatLong(47.6, -122.33), 10 ,'r' ,false);
    map.AttachEvent('onclick', openVirtualMap);
    }
    function openVirtualMap()
    {
    var mapwindow=window.open('map.html','mapwindow','width=790,height=620,menubar=no,location=no,status=no');
    mapwindow.focus();
    }
    </script>
    </head>
    <body onload="GetMap();">
    <div id='myMap' style="position:relative; width:400px; height:400px;"></div>
    </body>
    </html>


    works on my machine locally. I just click the map and then a new one pops up with the browser focused on the new one.


  • JimTan

    Ah but this is not working for me.

    I tried the same code. But it results into same. :(

    I was able to reproduce this problem on

    1. IE6
    2. IE7
    3. Firefox 2.0

    All of them.

    The window just pops up and again gets minimized.

    Even with the code you(Derek Chan) has provided the problem is still reproducible.

    What can the problem be :(



  • Vladox

    1. Security settings - Yes. I have allowed running activeX. The problem is still there.

    2. Yes . I already did the coding to make it work in firefox.

    3. No javascript errors. No error generated. Nor any exception thrown. Nothing to debug. :(

    The window just comes up and goes down sweetly.

    I just noticed that the only browser this code is working properly is Flock.



  • Urgent - Handling Map Click event