Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am looking for help to keep my tool tip on the a custom map. I have mouse over code that makes the tool tip display.

What needs to happen is on mouse over if the icon in close to the edge of map North, South, East and West the tool tip need to adjust to stay on the map. the default location is 1 PX top right of the icon. When it reaches the North edge of the map need to reappear at the bottom of the icon, if South edge reappear at the top of icon.

If east edge of map appear on the west side of icon if west edge of map appear on the east side of icon.


JavaScript
if (markerLayer) {
   var marker = new ALKMaps.Marker(pointLonLat, validIcon, name, extraInfo, { mouseOver: true, offset: { x: 16, y: 2 } });
   if (oldposition != null) {
      marker.events.register("mouseover", marker,
         function (evt) {
            extraInfo.panMapIfOutOfView = false;
            var newicon = validIcon.imageDiv.lastChild;
            var position = getPosition(newicon);
            var newpositionxh = position.x;
            var newpositionyv = position.y;
            var xposition = oldposition.x - 20;
            var yposition = oldposition.y - 20;

            if ((newpositionyv < yposition) && (newicon.lastChild.nodeValue)) {
               validIcon.imageDiv.lastElementChild.className = "lefttMarkerLabelTop";
            }
            if ((newpositionyv > yposition) && (newicon.lastChild.nodeValue)) {
               validIcon.imageDiv.lastElementChild.className = "rightMarkerLabelTop";
            }

            if ((newpositionxh < xposition) && (newpositionyv > yposition) && (newicon.lastChild.nodeValue)) {
               validIcon.imageDiv.lastElementChild.className = "rightMarkerLabelBottom";
            }

            if ((newpositionxh > xposition) && (newpositionyv < yposition) && (newicon.lastChild.nodeValue)) {
               validIcon.imageDiv.lastElementChild.className = "lefttMarkerLabelBottom";
            }
         }
      );
   }

the old position is the original location when the icon changes position. It check against.
Posted
Updated 2-Sep-15 5:04am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900