//center: centre du cercle type: GPoint
//radius: le rayon du cercle en metres
//numPoints: le nom de points d'approximation du cercle
function DrawCircle (center, radius, numPoints) {
    var a=map.fromDivPixelToLatLng(new GPoint(center.x,center.y));
    var b=map.fromDivPixelToLatLng(new GPoint(center.x+1,center.y));
    var dist = a.distanceFrom(b);

    var meters = (radius*1000/dist);
    var startRadians = 0;
    var points = [];

    for (var i = 0; i < numPoints; i++) {
        var radians = startRadians + 2 * Math.PI * i / numPoints;
        points.push(map.fromDivPixelToLatLng(new GPoint(
                center.x +  (Math.cos(radians))*meters,
                center.y +  (Math.sin(radians))*meters)));
    }
    points.push(points[0]);
    ct=map.fromDivPixelToLatLng(center);

    return new GPolyline(points,"#0000FF",3);
}

// Compare 2 points et vérfie si il sont proches
// a && b : GLtLng
function IsNear(a, b) {
    if (a instanceof EGeoXml) {
        apix = a.gpolylines[0].getBounds();
        //return false;
    } else {
        apix = map.fromLatLngToDivPixel(a.getPoint());
    }
    if (b instanceof EGeoXml) {
        bpix = b.gpolylines[0].getBounds();
        //return false;
    } else {
        bpix = map.fromLatLngToDivPixel(b.getPoint());
    }
    if (apix instanceof GPoint && bpix instanceof GPoint) {
        var dist = (apix.x - bpix.x) * (apix.x - bpix.x) + (apix.y - bpix.y) * (apix.y - bpix.y);
    } else {
        if (apix instanceof GPoint && bpix instanceof GLatLngBounds) {
            if (bpix.containsLatLng(a.getLatLng())) {
                return true;
            } else {
                return false;
            }
        }
        if (bpix instanceof GPoint && apix instanceof GLatLngBounds) {
            if (apix.containsLatLng(b.getLatLng())) {
                return true;
            } else {
                return false;
            }
        }
        if (bpix instanceof GLatLngBounds && apix instanceof GLatLngBounds) {
            if (apix.intersects(bpix)) {
                return true;
            } else {
                return false;
            }
        }        
    }
    //Mofifier (dist<200) pour changer le rayon de la zone dans laquelle deux marqueurs sont considérés comme proches.
    //dist est la distance au carré en pixel entre les deux points
    if (dist<200) return true;
    else return false;
}