please post the link, use googlepages if you don't have a site
already-
On Oct 15, 10:46 am, JMcC <[EMAIL PROTECTED]> wrote:
> Hi I was wondering if anyone can help me.
>
> I am looking to have a map where the user can select a location and a
> marker will appear on it with a circle drawn round it. The circle will
> have another marker with which the user can adjust the size of the
> circle.
>
> My problem. The whole thing works fine, I can place a marker on the
> screen where I want it and can change the diameter of the circle (by
> dragging the circle marker) and the polyline refreshes to the correct
> size. You can even move the centre (by dragging the centre marker) of
> the circle and the circle updates itself. The problem occurs when I
> place the centre markers on the map for the first time.
>
> I get the centre marker and the circle marker but no polyline. If I
> move the circle marker, still no polyline. It is not until I move the
> centre of the circle by the smallest amount that the whole thing
> updates itself and the poygon draws and then after that the polyline
> will update itself no matter what I do.
>
> Can anyone help me get the polygon to draw as soon as the markers are
> put on the map??
>
> Thanks in advance
>
> John
>
> Here is some code I have
>
> //this function places a marker at the centre of the circle and then a
> marker
> //a pre-set distance from the centre to be the boundary of the circle
> //I can place more than one marker set onscreen
>
> function placeMarkerAtPoint(lng, lat)
> {
>
> center[IconCount] = new GMarker(new GLatLng(lat,lng), {icon:icon,
> draggable: true});
> map.addOverlay(center[IconCount]);
> center[IconCount].enableDragging();
> GEvent.addListener(center[IconCount],'dragend',function()
> {drawCircle()});
> oldpoint = center[IconCount].getPoint();
>
> radius[IconCount] = new GMarker(new GLatLng(lat,(lng-0.018)),
> {icon:icon, draggable: true});
> map.addOverlay(radius[IconCount]);
> radius[IconCount].enableDragging();
> GEvent.addListener(radius[IconCount],'dragend',function()
> {drawCircle()});
>
> IconCount++;
> drawCircle();
>
> }
>
> //function which is called when one of the markers is dragged to a
> new
> //position and updates the screen. This should re-draw the polyline
> circle
>
> function drawCircle()
> {
>
> var point;
> var lat;
> var lng;
> var p;
> var x;
> var y;
> var Cradius;
> var Ccolor = '#0000ff' ; // color blue
> var Cwidth = 3 ; // width pixels
> var d2r = Math.PI/180 ; // degrees to radians
> var r2d = 180/Math.PI ; // radians to degrees
> var Clat; // using 3963 as earth's radius
> var Clng;
> var Cx;
> var Cy;
> var loopcount;
>
> for (loopcount=0; loopcount < IconCount; loopcount++)
> {
> point = center[loopcount].getPoint();
> lat = point.lat();
> lng = point.lng();
> if ( center[loopcount].oldpoint ) // Move radius when center is moved
> {
> p = radius[loopcount].getPoint();
> x = point.lat() - center[loopcount].oldpoint.lat();
> y = point.lng() - center[loopcount].oldpoint.lng();
> radius[loopcount].setPoint( new GLatLng( p.lat() + x, p.lng() + y) );}
>
> center[loopcount].oldpoint = point;
>
> Cradius = point.distanceFrom(radius[loopcount].getPoint()) *
> 0.000621371192;
> Clat = (Cradius/3963) * r2d; // using 3963 as earth's radius
> Clng = Clat/Math.cos(lat*d2r);
> var Cpoints=[];
> for (var i = 0 ; i < 13 ; i++)
> {
> var theta = Math.PI * (i/6);
> Cx = lng + (Clng * Math.cos(theta));
> Cy = lat + (Clat * Math.sin(theta));
> Cpoints.push(new GPoint(Cx,Cy));
>
> }
>
> // i think it is at this point here where the problem lies.
> // I have found through some debugging that the points to plot
> // the polyline are stored in Cpoints
> // For some reason this part will only work then the centre point has
> // been moved once
>
> if ( circle[loopcount] )
> {
> map.removeOverlay(circle[loopcount]);}
>
> circle[loopcount] = new GPolyline(Cpoints,Ccolor,Cwidth);
> map.addOverlay(circle[loopcount]);
>
> }
> }
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---