Note that there are some explanatory texts on larger screens.

plurals
  1. POConverting a class from Mootools to jQuery or classic javascript
    primarykey
    data
    text
    <p>Following Mootools class helps developer to draw a circle overlay on Google Map using Google Maps API v3. I'm using jQuery in my projects and entry-level knowledge in Object-oriented javascript.</p> <p>In Google Maps API v2, this is very easy but API v3 currently haven't built-in methods for drawing circles on map. Plus, in API documentation, there are <a href="http://code.google.com/intl/tr/apis/maps/documentation/v3/overlays.html#Drawing" rel="nofollow noreferrer">some description</a> for this can be done with different way.</p> <p>I want to use following CircleOverlay method in my project with jQuery or classic Javascript.</p> <p>Can anyone help for convert following Mootools lines to jQuery-enabled or classic javascript approach?</p> <pre><code>var CircleOverlay = new Class({ Implements: [Options], options: { numPoints: 100, drawOptions: { strokeColor: "#FF0000", strokeOpacity: 0.8, strokeWeight: 2, fillColor: "#FF0000", fillOpacity: 0.35 } }, initialize: function(map, center, radius, options) { this.setOptions(options); google.maps.OverlayView.call(this); var q = 180 / 63781370 / Math.sin(90 - center.lat()) / Math.PI; this._map = map; this._point = center; this._radius = radius * q * 10; // convert meters to latlang degrees // Fit bounds of a circle that is drawn into the map var d2r = Math.PI / 180; this.circleLatLngs = new Array(); var circleLat = this._radius; var circleLng = circleLat / Math.cos(center.lat() * d2r); this.latlngbounds = new google.maps.LatLngBounds(); // 2PI = 360 degrees, +1 so that the end points meet for (var i = 0; i &lt; this.options.numPoints + 1; i++) { var theta = Math.PI * (i / (this.options.numPoints / 2)); var vertexLat = center.lat() + (circleLat * Math.sin(theta)); var vertexLng = parseFloat(center.lng()) + parseFloat((circleLng * Math.cos(theta))); var vertextLatLng = new google.maps.LatLng(vertexLat, vertexLng); this.circleLatLngs.push(vertextLatLng); this.latlngbounds.extend(vertextLatLng); } map.fitBounds(this.latlngbounds); this.setMap(map); }, onAdd: function() { var polyOptions = this.options.drawOptions; polyOptions.paths = this.circleLatLngs; this.polygon = new google.maps.Polygon(polyOptions); this.polygon.setMap(this.map); }, onRemove: function() { this.polygon.setMap(null); }, draw: function() { this.onRemove(); this.onAdd(); } }); CircleOverlay.implement(new google.maps.OverlayView()); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload