I have write the following code, and trying to draw a rectangle, but I
can't see the rectangle, Can anybody tell me what's the problem,  I am
new developer...

        function loadMap()
        {

                var points=[];
                var lines =[];
                var map = new GMap2(document.getElementById("map"));
                map.setCenter(new GLatLng(51.0799,-114.132628), 18);
                map.setMapType(G_HYBRID_MAP);
                map.addControl(new GLargeMapControl());
                map.addControl(new GMapTypeControl());
                map.addControl(new GOverviewMapControl());

                GEvent.addListener(map, "click", function(overlay, point)
                        {

                                map.clearOverlays();
                                if (point)
                                {

                                        map.addOverlay(new GMarker(point));
                                        map.panTo(point);
                                        points.push(point);

                                }

                                if (points.length ==2)
                                {

                                        var pts1 = new 
GLatLng(points[0].lat(),points[0].lng());
                                        var pts2 = new 
GLatLng(points[1].lat(),points[0].lng());
                                        var pts3 = new 
GLatLng(points[0].lat(),points[1].lng());
                                        var pts4 = new 
GLatLng(points[1].lat(),points[1].lng());


                                     var boxPoints=[];
                                         boxPoints.push(pts1);
                                         boxPoints.push(pts2);
                                         boxPoints.push(pts3);
                                         boxPoints.push(pts4);
                                         var boxPoly = new 
GPolygon(boxPoints,"#ff0000",1,0.7,0.7,0.7);
                                         map.addOverlay(boxPoly);

                                }

                });  //end of GEvent

        }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to