1/** 2 * @namespace WPGMZA 3 * @module GooglePolyline 4 * @requires WPGMZA.Polyline 5 * @pro-requires WPGMZA.ProPolyline 6 */ 7jQuery(function($) { 8 9 var Parent; 10 11 WPGMZA.GooglePolyline = function(options, googlePolyline) { 12 13 var self = this; 14 15 Parent.call(this, options, googlePolyline); 16 17 if(googlePolyline) { 18 this.googlePolyline = googlePolyline; 19 } else { 20 this.googlePolyline = new google.maps.Polyline(this.settings); 21 } 22 23 24 this.googleFeature = this.googlePolyline; 25 26 if(options && options.polydata) 27 { 28 29 var path = this.parseGeometry(options.polydata); 30 this.googlePolyline.setPath(path); 31 } 32 33 this.googlePolyline.wpgmzaPolyline = this; 34 35 if(options) 36 this.setOptions(options); 37 38 google.maps.event.addListener(this.googlePolyline, "click", function(event) { 39 let coordinates = new WPGMZA.LatLng(event.latLng.lat(), event.latLng.lng()); 40 self.dispatchEvent({type: "click", coordinates : coordinates}); 41 }); 42 } 43 44 if(WPGMZA.isProVersion()) 45 Parent = WPGMZA.ProPolyline; 46 else 47 Parent = WPGMZA.Polyline; 48 49 WPGMZA.GooglePolyline.prototype = Object.create(Parent.prototype); 50 WPGMZA.GooglePolyline.prototype.constructor = WPGMZA.GooglePolyline; 51 52 WPGMZA.GooglePolyline.prototype.updateNativeFeature = function() { 53 this.googlePolyline.setOptions(WPGMZA.GoogleFeature.getGoogleStyle(this.getScalarProperties())); 54 } 55 56 WPGMZA.GooglePolyline.prototype.setEditable = function(value) { 57 var self = this; 58 59 this.googlePolyline.setOptions({editable: value}); 60 61 62 63 if (value) { 64 // TODO: Unbind these when value is false 65 var path = this.googlePolyline.getPath(); 66 var events = [ 67 "insert_at", 68 "remove_at", 69 "set_at" 70 ]; 71 72 events.forEach(function(name) { 73 google.maps.event.addListener(path, name, function() { 74 self.trigger("change"); 75 }) 76 }); 77 78 // TODO: Add dragging and listen for dragend 79 google.maps.event.addListener(this.googlePolyline, "dragend", function(event) { 80 self.trigger("change"); 81 }); 82 83 google.maps.event.addListener(this.googlePolyline, "click", function(event) { 84 if(!WPGMZA.altKeyDown) 85 return; 86 87 var path = this.getPath(); 88 path.removeAt(event.vertex); 89 self.trigger("change"); 90 91 }); 92 } 93 } 94 95 WPGMZA.GooglePolyline.prototype.setVisible = function(visible) { 96 this.googlePolyline.setVisible(visible ? true : false); 97 } 98 99 WPGMZA.GooglePolyline.prototype.setDraggable = function(value) { 100 this.googlePolyline.setOptions({draggable: value}); 101 } 102 103 WPGMZA.GooglePolyline.prototype.getGeometry = function() { 104 105 var result = []; 106 107 var path = this.googlePolyline.getPath(); 108 for(var i = 0; i < path.getLength(); i++) 109 { 110 var latLng = path.getAt(i); 111 result.push({ 112 lat: latLng.lat(), 113 lng: latLng.lng() 114 }); 115 } 116 117 return result; 118 } 119 120});
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.