Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i am trying to add tooltip on polygon on mouseover event

but it cannot getting coordinate of polygon on mouse over

here is code to create polygon and added mouse over event in the end of function (attachPolygonInfoWindow())...........

C#
function editShape() {

            var hdncolor;
            var color;
            color = "#0000FF";
            //  var color = getColor(false);
            var points = [];
            var _Polygons = [];
            _Polygons = document.getElementById("PointsBox").value.split('?');

            for (var j = 0; j <= _Polygons.length - 1; j++) {
                debugger;
                var inputPolygon = _Polygons[j];
                pointsLines = inputPolygon.split(/ |\n/);
                var poly = new GPolygon([], color, 2, 0.7, color, 0.2);
                //var poly = new GPolyline([],color,lineWeight,opacity);
                //Read in coordinates
                for (var i = 0, len = pointsLines.length; i < len; ++i) {

                    if (pointsLines[i].search(/,|\t/) != -1) {
                        pointsCoords = pointsLines[i].split(/,|\t/);
                        if (parseFloat(pointsCoords[0]) != 0 && parseFloat(pointsCoords[1]) != 0) {
                            poly.insertVertex(0, new GLatLng(parseFloat(pointsCoords[0]), parseFloat(pointsCoords[1])));
                        }
                    }
                }
                map.addOverlay(poly);

                var name = "Polygon " + (++shapeCounter_);
                var cells = addFeatureEntry(name, color);

                // poly.enableEditing({ onEvent: "mouseover" });
                poly.disableEditing({ onEvent: "mouseout" });
                poly.disableEditing({ onEvent: "mouseover" });
                poly.Nametag = name;
                currpoly = poly;
                logCoordinates(poly);
                cells.desc.innerHTML = " (" + poly.getVertexCount() + " points)";
                GEvent.bind(poly, "lineupdated", cells.desc, function () {
                    logCoordinates(poly);
                    var cell = this;
                    cell.innerHTML = " (" + poly.getVertexCount() + " points)";
                });
                GEvent.addListener(poly, "click", function (latlng, index) {

                    currpoly = poly;
                    if (typeof index == "number") {
                        poly.deleteVertex(index);
                    } else {
                        //poly.setFillStyle({color: "#0000FF"});
                        poly.setStrokeStyle({ weight: 2 });
                        //poly.redraw(true);
                        cells.desc.innerHTML = " (" + poly.getVertexCount() + " points)";
                    }
                });
                debugger
               // GEvent.addListener(map, 'mouseover', showArrays);

                 attachPolygonInfoWindow(poly , '<strong>Info about this area</strong>');

            }
        }



C#
function attachPolygonInfoWindow(poly, html) {
          debugger;
          poly.infoWindow = new google.maps.InfoWindow({
              content: html
          });
          GEvent.addListener(poly, 'mouseover', function (e) {
              debugger;
              var latLng = e.latLng;
              //this.setOptions({ fillOpacity: 0.1 });
              poly.infoWindow.setPosition(latLng);
              poly.infoWindow.open(map);
          });
         // GEvent.addListener(poly, 'mouseout', function () {
         //     debugger;
         //     //this.setOptions({ fillOpacity: 0.35 });
          //    poly.infoWindow.close();
        //  });
      }



it is not working because it not getting latlog on mouseover
plz help....
Posted
Updated 8-Jun-12 20:35pm
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