PageSourceSearch

https://eurosdr.net/sites/all/modules/contrib/gmap/js/poly.js?tlvrdx

js eurosdr.net collected 2026-09-24 19:06:34 UTC 1,908 bytes, 64 lines download raw bytes

1/**
2 * @file
3 * GPolyLine / GPolygon manager
4 */
5
6/*global Drupal, GLatLng, GPoint */
7
8Drupal.gmap.map.prototype.poly = {};
9
10/**
11 * Distance in pixels between 2 points.
12 */
13Drupal.gmap.map.prototype.poly.distance = function (point1, point2) {
14    return Math.sqrt(Math.pow(point2.x - point1.x, 2) + Math.pow(point2.y - point1.y, 2));
15};
16
17/**
18 * Circle -- Following projection.
19 */
20Drupal.gmap.map.prototype.poly.computeCircle = function (obj, center, point2) {
21    var numSides = 36;
22    var sideInc = 10; // 360 / 20 = 18 degrees
23    var convFactor = Math.PI / 180;
24    var points = [];
25    var radius = obj.poly.distance(center, point2);
26    // 36 sided poly ~= circle
27    for (var i = 0; i <= numSides; i++) {
28        var rad = i * sideInc * convFactor;
29        var x = center.x + radius * Math.cos(rad);
30        var y = center.y + radius * Math.sin(rad);
31        //points.push(obj.map.getCurrentMapType().getProjection().fromPixelToLatLng(new GPoint(x,y),obj.map.getZoom()));
32        points.push(new GPoint(x, y));
33    }
34    return points;
35};
36
37Drupal.gmap.map.prototype.poly.calcPolyPoints = function (center, radM, numPoints, sAngle) {
38    if (!numPoints) {
39        numPoints = 32;
40    }
41    if (!sAngle) {
42        sAngle = 0;
43    }
44
45    var d2r = Math.PI / 180.0;
46    var r2d = 180.0 / Math.PI;
47    var angleRad = sAngle * d2r;
48    // earth semi major axis is about 6378137 m
49    var latScale = radM / 6378137 * r2d;
50    var lngScale = latScale / Math.cos(center.latRadians());
51
52    var angInc = 2 * Math.PI / numPoints;
53    var points = [];
54    for (var i = 0; i < numPoints; i++) {
55        var lat = parseFloat(center.lat()) + latScale * Math.sin(angleRad);
56        var lng = parseFloat(center.lng()) + lngScale * Math.cos(angleRad);
57        points.push(new GLatLng(lat, lng));
58        angleRad += angInc;
59    }
60
61    // close the shape and return it
62    points.push(points[0]);
63    return points;
64};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.