Calculating radius and distance

HTML

<html>
    <head>
        <script type="text/javascript" src="http://www.google.com/jsapi?autoload={'modules':[{name:'maps',version:3,other_params:'sensor=false'}]}"></script>
    </head>
    <body>
        <div id="map-canvas"></div>
        <div id="info">
        </div>
        <div id='geocode'>
        <input name="q" type="text" id="q" /><br />
                <input type="submit" value="Submit" id="geosubmit" /></div>
    </body>
</html>

JavaScript

//StackOverflow: http://stackoverflow.com/questions/5340940/google-maps-api-v3-geocoding

function DistanceWidget(map) {
    this.set('map', map);
    this.set('position', map.getCenter());
    var marker = new google.maps.Marker({
        draggable: true
    });
    marker.bindTo('map', this);
    marker.bindTo('position', this);
    var radiusWidget = new RadiusWidget();
    radiusWidget.bindTo('map', this);
    radiusWidget.bindTo('center', this, 'position');
    this.bindTo('distance', radiusWidget);
    this.bindTo('bounds', radiusWidget);
}
DistanceWidget.prototype = new google.maps.MVCObject();

function RadiusWidget() {
    var circle = new google.maps.Circle({
        fillColor: '#efefef',
        fillOpacity: 0.5,
        strokeColor: '#000',
        strokeOpacity: 1.0,
        strokeWeight: 2
    });
    this.set('distance', 1);
    this.bindTo('bounds', circle);
    circle.bindTo('center', this);
    circle.bindTo('map', this);
    circle.bindTo('radius', this);
    this.addSizer_();
}
RadiusWidget.prototype = new google.maps.MVCObject();
RadiusWidget.prototype.distance_changed = function() {
    this.set('radius', this.get('distance') * 1);
};
RadiusWidget.prototype.addSizer_ = function() {
    var sizer = new google.maps.Marker({
        draggable: true
    });
    sizer.bindTo('map', this);
    sizer.bindTo('position', this, 'sizer_position');
    var me = this;
    google.maps.event.addListener(sizer, 'drag', function() {
        me.setDistance();
    });
};
RadiusWidget.prototype.center_changed = function() {
    var bounds = this.get('bounds');
    if (bounds) {
        var lng = bounds.getNorthEast().lng();
        var position = new google.maps.LatLng(this.get('center').lat(), lng);
        this.set('sizer_position', position);
    }
};

RadiusWidget.prototype.distanceBetweenPoints_ = function(p1, p2) {
    if (!p1 || !p2) {
        return 0;
    }
    var R = 6371;
    var dLat = (p2.lat() - p1.lat()) * Math.PI / 180;
    var dLon = (p2.lng()...