Implementing new way for map.addCircle()
MODIFY
www/BaseClass.js
www/BaseClass.js
@@ -7,7 +7,9 @@ function BaseClass() {
this[SUBSCRIPTIONS_FIELD] = {};
this.errorHandler = this.errorHandler.bind(this);
- Object.defineProperty(this, 'hashCode', { value: Math.floor(Date.now() * Math.random()) });
+ Object.defineProperty(this, 'hashCode', {
+ value: Math.floor(Date.now() * Math.random())
+ });
}
BaseClass.prototype = {
@@ -45,7 +47,6 @@ BaseClass.prototype = {
target.set(targetKey, target.get(targetKey), noNotify);
this.on(key + '_changed', function(oldValue, value) {
-console.log(key, value);
target.set(targetKey, value);
});
},
@@ -146,8 +147,12 @@ function createError(message, methodName, args) {
].join('') : message);
Object.defineProperties(error, {
- methodName: { value: methodName },
- args: { value: args }
+ methodName: {
+ value: methodName
+ },
+ args: {
+ value: args
+ }
});
return error;

MODIFY
www/Circle.js
www/Circle.js
@@ -7,10 +7,8 @@ var argscheck = require('cordova/argscheck'),
/*****************************************************************************
* Circle Class
*****************************************************************************/
-var exec;
-var Circle = function(map, circleOptions, _exec) {
- exec = _exec;
- Overlay.call(this, map, circleOptions, _exec);
+var Circle = function(map, circleOptions, className, _exec) {
+ Overlay.call(this, map, circleOptions, className, _exec);
var self = this;
@@ -19,35 +17,35 @@ var Circle = function(map, circleOptions, _exec) {
//-----------------------------------------------
self.on("center_changed", function() {
var center = self.get("center");
- exec.call(self, null, self.errorHandler, self.getPluginName(), 'setCenter', [self.getId(), center.lat, center.lng]);
+ self.exec.call(self, null, self.errorHandler, self.getPluginName(), 'setCenter', [self.getId(), center.lat, center.lng]);
});
self.on("fillColor_changed", function() {
var color = self.get("fillColor");
- exec.call(self, null, self.errorHandler, self.getPluginName(), 'setFillColor', [self.getId(), common.HTMLColor2RGBA(color, 0.75)]);
+ self.exec.call(self, null, self.errorHandler, self.getPluginName(), 'setFillColor', [self.getId(), common.HTMLColor2RGBA(color, 0.75)]);
});
self.on("strokeColor_changed", function() {
var color = self.get("strokeColor");
- exec.call(self, null, self.errorHandler, self.getPluginName(), 'setStrokeColor', [self.getId(), common.HTMLColor2RGBA(color, 0.75)]);
+ self.exec.call(self, null, self.errorHandler, self.getPluginName(), 'setStrokeColor', [self.getId(), common.HTMLColor2RGBA(color, 0.75)]);
});
self.on("strokeWidth_changed", function() {
var width = self.get("strokeWidth");
- exec.call(self, null, self.errorHandler, self.getPluginName(), 'setStrokeWidth', [self.getId(), width]);
+ self.exec.call(self, null, self.errorHandler, self.getPluginName(), 'setStrokeWidth', [self.getId(), width]);
});
self.on("clickable_changed", function() {
var clickable = self.get("clickable");
- exec.call(self, null, self.errorHandler, self.getPluginName(), 'setClickable', [self.getId(), clickable]);
+ self.exec.call(self, null, self.errorHandler, self.getPluginName(), 'setClickable', [self.getId(), clickable]);
});
self.on("radius_changed", function() {
var radius = self.get("radius");
- exec.call(self, null, self.errorHandler, self.getPluginName(), 'setRadius', [self.getId(), radius]);
+ self.exec.call(self, null, self.errorHandler, self.getPluginName(), 'setRadius', [self.getId(), radius]);
});
self.on("zIndex_changed", function() {
var zIndex = self.get("zIndex");
- exec.call(self, null, self.errorHandler, self.getPluginName(), 'setZIndex', [self.getId(), zIndex]);
+ self.exec.call(self, null, self.errorHandler, self.getPluginName(), 'setZIndex', [self.getId(), zIndex]);
});
self.on("visible_changed", function() {
var visible = self.get("visible");
- exec.call(self, null, self.errorHandler, self.getPluginName(), 'setVisible', [self.getId(), visible]);
+ self.exec.call(self, null, self.errorHandler, self.getPluginName(), 'setVisible', [self.getId(), visible]);
});
};
@@ -125,7 +123,9 @@ Circle.prototype.remove = function(callback) {
if (typeof callback === "function") {
callback.call(self);
}
- }, self.errorHandler, self.getPluginName(), 'remove', [self.getId()], {remove: true});
+ }, self.errorHandler, self.getPluginName(), 'remove', [self.getId()], {
+ remove: true
+ });
};
Circle.prototype.getBounds = function() {
@@ -145,7 +145,10 @@ Circle.prototype.getBounds = function() {
for (var i = 0; i < 360; i += 90) {
ey = center.lng + (rlng * Math.cos(i * d2r)); // center a + radius x * cos(theta)
ex = center.lat + (rlat * Math.sin(i * d2r)); // center b + radius y * sin(theta)
- bounds.extend({lat: ex, lng: ey});
+ bounds.extend({
+ lat: ex,
+ lng: ey
+ });
}
return bounds;
};

MODIFY
www/Map.js
www/Map.js
@@ -1138,7 +1138,14 @@ Map.prototype.addCircle = function(circleOptions, callback) {
circle = undefined;
});
- exec.call(this, callback, self.errorHandler, self.id, 'loadPlugin', ['Circle', circleOptions, circle.hashCode]);
+ exec.call(this, function(result) {
+ circle._privateInitialize();
+ delete circle._privateInitialize;
+
+ if (typeof callback === "function") {
+ callback.call(self, circle);
+ }
+ }, self.errorHandler, self.id, 'loadPlugin', ['Circle', circleOptions, circle.hashCode]);
return circle;
};
@@ -1299,6 +1306,7 @@ Map.prototype._onMapEvent = function(eventName) {
Map.prototype._onMarkerEvent = function(eventName, markerId, position) {
var self = this;
var marker = self.MARKERS[markerId] || null;
+
if (marker) {
marker.set('position', position);
if (eventName === event.INFO_OPEN) {

- Implementing new way for map.addCircle()