Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:58:27

0001 GMaps.prototype.drawPolyline = function(options) {
0002   var path = [],
0003       points = options.path;
0004 
0005   if (points.length) {
0006     if (points[0][0] === undefined) {
0007       path = points;
0008     }
0009     else {
0010       for (var i = 0, latlng; latlng = points[i]; i++) {
0011         path.push(new google.maps.LatLng(latlng[0], latlng[1]));
0012       }
0013     }
0014   }
0015 
0016   var polyline_options = {
0017     map: this.map,
0018     path: path,
0019     strokeColor: options.strokeColor,
0020     strokeOpacity: options.strokeOpacity,
0021     strokeWeight: options.strokeWeight,
0022     geodesic: options.geodesic,
0023     clickable: true,
0024     editable: false,
0025     visible: true
0026   };
0027 
0028   if (options.hasOwnProperty("clickable")) {
0029     polyline_options.clickable = options.clickable;
0030   }
0031 
0032   if (options.hasOwnProperty("editable")) {
0033     polyline_options.editable = options.editable;
0034   }
0035 
0036   if (options.hasOwnProperty("icons")) {
0037     polyline_options.icons = options.icons;
0038   }
0039 
0040   if (options.hasOwnProperty("zIndex")) {
0041     polyline_options.zIndex = options.zIndex;
0042   }
0043 
0044   var polyline = new google.maps.Polyline(polyline_options);
0045 
0046   var polyline_events = ['click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];
0047 
0048   for (var ev = 0; ev < polyline_events.length; ev++) {
0049     (function(object, name) {
0050       if (options[name]) {
0051         google.maps.event.addListener(object, name, function(e){
0052           options[name].apply(this, [e]);
0053         });
0054       }
0055     })(polyline, polyline_events[ev]);
0056   }
0057 
0058   this.polylines.push(polyline);
0059 
0060   GMaps.fire('polyline_added', polyline, this);
0061 
0062   return polyline;
0063 };
0064 
0065 GMaps.prototype.removePolyline = function(polyline) {
0066   for (var i = 0; i < this.polylines.length; i++) {
0067     if (this.polylines[i] === polyline) {
0068       this.polylines[i].setMap(null);
0069       this.polylines.splice(i, 1);
0070 
0071       GMaps.fire('polyline_removed', polyline, this);
0072 
0073       break;
0074     }
0075   }
0076 };
0077 
0078 GMaps.prototype.removePolylines = function() {
0079   for (var i = 0, item; item = this.polylines[i]; i++) {
0080     item.setMap(null);
0081   }
0082 
0083   this.polylines = [];
0084 };
0085 
0086 GMaps.prototype.drawCircle = function(options) {
0087   options =  extend_object({
0088     map: this.map,
0089     center: new google.maps.LatLng(options.lat, options.lng)
0090   }, options);
0091 
0092   delete options.lat;
0093   delete options.lng;
0094 
0095   var polygon = new google.maps.Circle(options),
0096       polygon_events = ['click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];
0097 
0098   for (var ev = 0; ev < polygon_events.length; ev++) {
0099     (function(object, name) {
0100       if (options[name]) {
0101         google.maps.event.addListener(object, name, function(e){
0102           options[name].apply(this, [e]);
0103         });
0104       }
0105     })(polygon, polygon_events[ev]);
0106   }
0107 
0108   this.polygons.push(polygon);
0109 
0110   return polygon;
0111 };
0112 
0113 GMaps.prototype.drawRectangle = function(options) {
0114   options = extend_object({
0115     map: this.map
0116   }, options);
0117 
0118   var latLngBounds = new google.maps.LatLngBounds(
0119     new google.maps.LatLng(options.bounds[0][0], options.bounds[0][1]),
0120     new google.maps.LatLng(options.bounds[1][0], options.bounds[1][1])
0121   );
0122 
0123   options.bounds = latLngBounds;
0124 
0125   var polygon = new google.maps.Rectangle(options),
0126       polygon_events = ['click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];
0127 
0128   for (var ev = 0; ev < polygon_events.length; ev++) {
0129     (function(object, name) {
0130       if (options[name]) {
0131         google.maps.event.addListener(object, name, function(e){
0132           options[name].apply(this, [e]);
0133         });
0134       }
0135     })(polygon, polygon_events[ev]);
0136   }
0137 
0138   this.polygons.push(polygon);
0139 
0140   return polygon;
0141 };
0142 
0143 GMaps.prototype.drawPolygon = function(options) {
0144   var useGeoJSON = false;
0145 
0146   if(options.hasOwnProperty("useGeoJSON")) {
0147     useGeoJSON = options.useGeoJSON;
0148   }
0149 
0150   delete options.useGeoJSON;
0151 
0152   options = extend_object({
0153     map: this.map
0154   }, options);
0155 
0156   if (useGeoJSON == false) {
0157     options.paths = [options.paths.slice(0)];
0158   }
0159 
0160   if (options.paths.length > 0) {
0161     if (options.paths[0].length > 0) {
0162       options.paths = array_flat(array_map(options.paths, arrayToLatLng, useGeoJSON));
0163     }
0164   }
0165 
0166   var polygon = new google.maps.Polygon(options),
0167       polygon_events = ['click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];
0168 
0169   for (var ev = 0; ev < polygon_events.length; ev++) {
0170     (function(object, name) {
0171       if (options[name]) {
0172         google.maps.event.addListener(object, name, function(e){
0173           options[name].apply(this, [e]);
0174         });
0175       }
0176     })(polygon, polygon_events[ev]);
0177   }
0178 
0179   this.polygons.push(polygon);
0180 
0181   GMaps.fire('polygon_added', polygon, this);
0182 
0183   return polygon;
0184 };
0185 
0186 GMaps.prototype.removePolygon = function(polygon) {
0187   for (var i = 0; i < this.polygons.length; i++) {
0188     if (this.polygons[i] === polygon) {
0189       this.polygons[i].setMap(null);
0190       this.polygons.splice(i, 1);
0191 
0192       GMaps.fire('polygon_removed', polygon, this);
0193 
0194       break;
0195     }
0196   }
0197 };
0198 
0199 GMaps.prototype.removePolygons = function() {
0200   for (var i = 0, item; item = this.polygons[i]; i++) {
0201     item.setMap(null);
0202   }
0203 
0204   this.polygons = [];
0205 };