vendor/assets/javascripts/map.js in flashgrid-2.0.1 vs vendor/assets/javascripts/map.js in flashgrid-2.1.0

- old
+ new

@@ -493,10 +493,14 @@ if (options.content) { control.innerHTML = options.content; } + if (options.position) { + control.position = google.maps.ControlPosition[options.position.toUpperCase()]; + } + for (var ev in options.events) { (function(object, name) { google.maps.event.addDomListener(object, name, function(){ options.events[name].apply(this, [this]); }); @@ -507,19 +511,37 @@ return control; }; GMaps.prototype.addControl = function(options) { - var position = google.maps.ControlPosition[options.position.toUpperCase()]; - - delete options.position; - var control = this.createControl(options); this.controls.push(control); + this.map.controls[control.position].push(control); - this.map.controls[position].push(control); + return control; +}; +GMaps.prototype.removeControl = function(control) { + var position = null; + + for (var i = 0; i < this.controls.length; i++) { + if (this.controls[i] == control) { + position = this.controls[i].position; + this.controls.splice(i, 1); + } + } + + if (position) { + for (i = 0; i < this.map.controls.length; i++) { + var controlsForPosition = this.map.controls[control.position] + if (controlsForPosition.getAt(i) == control) { + controlsForPosition.removeAt(i); + break; + } + } + } + return control; }; GMaps.prototype.createMarker = function(options) { if (options.lat == undefined && options.lng == undefined && options.position == undefined) { @@ -1359,10 +1381,11 @@ this.getRoutes({ origin: options.origin, destination: options.destination, travelMode: options.travelMode, waypoints : options.waypoints, + unitSystem: options.unitSystem, error: options.error, callback: function(e) { //start callback if (e.length > 0 && options.start) { options.start(e[e.length - 1]); @@ -1692,16 +1715,16 @@ /** Map Styles **/ if (styles) { for (var i = 0; i < styles.length; i++) { var styleRule = []; - if (styles[i].featureType && styles[i].featureType != 'all' ) { - styleRule.push('feature:' + styles[i].featureType); + if (styles[i].featureType){ + styleRule.push('feature:' + styles[i].featureType.toLowerCase()); } - if (styles[i].elementType && styles[i].elementType != 'all') { - styleRule.push('element:' + styles[i].elementType); + if (styles[i].elementType) { + styleRule.push('element:' + styles[i].elementType.toLowerCase()); } for (var j = 0; j < styles[i].stylers.length; j++) { for (var p in styles[i].stylers[j]) { var ruleArg = styles[i].stylers[j][p]; @@ -1876,10 +1899,11 @@ GMaps.custom_events = ['marker_added', 'marker_removed', 'polyline_added', 'polyline_removed', 'polygon_added', 'polygon_removed', 'geolocated', 'geolocation_failed']; GMaps.on = function(event_name, object, handler) { if (GMaps.custom_events.indexOf(event_name) == -1) { + if(object instanceof GMaps) object = object.map; return google.maps.event.addListener(object, event_name, handler); } else { var registered_event = { handler : handler, @@ -1893,9 +1917,10 @@ } }; GMaps.off = function(event_name, object) { if (GMaps.custom_events.indexOf(event_name) == -1) { + if(object instanceof GMaps) object = object.map; google.maps.event.clearListeners(object, event_name); } else { object.registered_events[event_name] = []; } \ No newline at end of file