1/** 2 * @namespace WPGMZA 3 * @module GoogleCircle 4 * @requires WPGMZA.Circle 5 * @pro-requires WPGMZA.ProCircle 6 */ 7jQuery(function($) { 8 9 var Parent = WPGMZA.Circle; 10 /** 11 * Subclass, used when Google is the maps engine. <strong>Please <em>do not</em> call this constructor directly. Always use createInstance rather than instantiating this class directly.</strong> Using createInstance allows this class to be externally extensible. 12 * @class WPGMZA.GoogleCircle 13 * @constructor WPGMZA.GoogleCircle 14 * @memberof WPGMZA 15 * @augments WPGMZA.Circle 16 * @see WPGMZA.Circle.createInstance 17 */ 18 WPGMZA.GoogleCircle = function(options, googleCircle) 19 { 20 var self = this; 21 22 Parent.call(this, options, googleCircle); 23 24 if(googleCircle) 25 { 26 this.googleCircle = googleCircle; 27 28 if(options) 29 { 30 31 options.center = WPGMZA.LatLng.fromGoogleLatLng( googleCircle.getCenter() ); 32 options.radius = googleCircle.getRadius() / 1000; // Meters to kilometers 33 } 34 } 35 else 36 { 37 this.googleCircle = new google.maps.Circle(); 38 this.googleCircle.wpgmzaCircle = this; 39 } 40 41 this.googleFeature = this.googleCircle; 42 43 if(options) 44 this.setOptions(options); 45 46 google.maps.event.addListener(this.googleCircle, "click", function() { 47 self.dispatchEvent({type: "click"}); 48 }); 49 50 google.maps.event.addListener(this.googleCircle, "rightclick", function(event) { 51 if(typeof self.map !== 'undefined' && self.map instanceof WPGMZA.Map){ 52 var wpgmzaEvent = new WPGMZA.Event("rightclick"); 53 wpgmzaEvent.latLng = { 54 lat: event.latLng.lat(), 55 lng: event.latLng.lng() 56 }; 57 58 self.map.dispatchEvent(wpgmzaEvent); 59 } 60 }); 61 } 62 63 if(WPGMZA.isProVersion()) 64 Parent = WPGMZA.ProCircle; 65 66 WPGMZA.GoogleCircle.prototype = Object.create(Parent.prototype); 67 WPGMZA.GoogleCircle.prototype.constructor = WPGMZA.GoogleCircle; 68 69 WPGMZA.GoogleCircle.prototype.getCenter = function() 70 { 71 return WPGMZA.LatLng.fromGoogleLatLng( this.googleCircle.getCenter() ); 72 } 73 74 WPGMZA.GoogleCircle.prototype.setCenter = function(center) 75 { 76 WPGMZA.Circle.prototype.setCenter.apply(this, arguments); 77 78 this.googleCircle.setCenter(center); 79 } 80 81 WPGMZA.GoogleCircle.prototype.getRadius = function() 82 { 83 return this.googleCircle.getRadius() / 1000; // Meters to kilometers 84 } 85 86 WPGMZA.GoogleCircle.prototype.setRadius = function(radius) 87 { 88 WPGMZA.Circle.prototype.setRadius.apply(this, arguments); 89 90 this.googleCircle.setRadius(parseFloat(radius) * 1000); // Kilometers to meters 91 } 92 93 WPGMZA.GoogleCircle.prototype.setVisible = function(visible) 94 { 95 this.googleCircle.setVisible(visible ? true : false); 96 } 97 98 WPGMZA.GoogleCircle.prototype.setDraggable = function(value) 99 { 100 this.googleCircle.setDraggable(value ? true : false); 101 } 102 103 WPGMZA.GoogleCircle.prototype.setEditable = function(value) 104 { 105 var self = this; 106 107 this.googleCircle.setOptions({editable: value}); 108 109 if(value) 110 { 111 google.maps.event.addListener(this.googleCircle, "center_changed", function(event) { 112 113 self.center = WPGMZA.LatLng.fromGoogleLatLng(self.googleCircle.getCenter()); 114 self.trigger("change"); 115 116 }); 117 118 google.maps.event.addListener(this.googleCircle, "radius_changed", function(event) { 119
120 self.radius = self.googleCircle.getRadius() / 1000; // Meters to kilometers 121 self.trigger("change"); 122 123 }); 124 } 125 } 126 127 WPGMZA.GoogleCircle.prototype.setOptions = function(options) 128 { 129 WPGMZA.Circle.prototype.setOptions.apply(this, arguments); 130 131 if(options.center) 132 this.center = new WPGMZA.LatLng(options.center); 133 } 134 135 WPGMZA.GoogleCircle.prototype.updateNativeFeature = function() 136 { 137 var googleOptions = this.getScalarProperties(); 138 var center = new WPGMZA.LatLng(this.center); // In case center is a lat lng literal, this should really happen though 139 140 googleOptions.radius *= 1000; // Kilometers to meters 141 googleOptions.center = center.toGoogleLatLng(); 142 143 this.googleCircle.setOptions(googleOptions); 144 } 145 146});
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.