Hi,

I would like to bind a line on the cursor. First I click on the map -
that is my startpoint for the line. By the second click the line is
finished.
It should looks like this example: 
http://gmaps-samples.googlecode.com/svn/trunk/poly/mymapstoolbar.html

Where is the bug in my code?

Thank you, for your help!!!

<body>
                <h1>Google Maps API-Circle</h1>
                <div id="map" style="width: 500px; height: 500px"></div>
                <script type="text/javascript">
                        //<![CDATA[
                        var zoom = 7;
                        var coordinate = new GLatLng(52.8,8.8);
                        if (GBrowserIsCompatible()) {
                                var map = new 
GMap2(document.getElementById("map"));
                                map.setCenter(coordinate, zoom);
                                map.enableScrollWheelZoom();
                                map.addControl(new GMapTypeControl());
                                map.addControl(new GSmallMapControl());
                                
map.getDragObject().setDraggableCursor("crosshair");

                                var count = 0;
                                var point1;
                                var point2;
                                var circle;
                                var color = "330000";
                                var line = new GPolyline([], color, 3, 9);
                                map.addOverlay(line);

                                GEvent.addListener(map,'click',
                                        function(overlay, point) {
                                                if (point) {
                                                        if (count == 0){
                                                                point1 = new 
GLatLng(point.y, point.x);
                                                                var marker = 
new GMarker(point1, {icon: getIcon(), draggable:
true, dragCrossMove: true});
                                                                
map.addOverlay(marker);
                                                                
line.insertVertex(0, point1);
                                                                
this.mouseMoveEvent = GEvent.bind(map, 'mousemove', this,
function(point){
                                                                        
line.deleteVertex(line.getVertexCount());
                                                                        
line.insertVertex(1, point);
                                                                });
                                                        }
                                                        if (count == 1){
                                                                point2 = new 
GLatLng(point.y, point.x);
                                                                var marker = 
new GMarker(point2, {icon: getIcon(), draggable:
true, dragCrossMove: true});
                                                                
map.addOverlay(marker);
                                                                marker.hide();
                                                                /**var circle = 
drawCircle(point1,
point2,"#0055ff","#997F99");
                                                                var area = 
circle.getArea();
                                                                
map.addOverlay(circle,logPoints(point1, point2, area));
                                                                
line.deleteVertex(1);
                                                                
line.insertVertex(count, point2);
                                                                
updateCircle(map, circle, point1, point2);      */
                                                        }
                                                        if(count == 1){
                                                                count = 0;
                                                        }
                                                        else{
                                                                count ++;
                                                        }
                                                }
                                        }
                                );
                        }
                        //]]>
                </script>
        </body>

-- 
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