Skip to content

Commit

Permalink
Add #59: Extend LatLngBounds and map.fitBounds()
Browse files Browse the repository at this point in the history
  • Loading branch information
wf9a5m75 committed May 18, 2014
1 parent d732f77 commit 84e1ed3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 97 deletions.
3 changes: 0 additions & 3 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
<source-file src="src/android/plugin/google/maps/PluginPolyline.java" target-dir="src/plugin/google/maps" />
<source-file src="src/android/plugin/google/maps/PluginTileOverlay.java" target-dir="src/plugin/google/maps" />
<source-file src="src/android/plugin/google/maps/PluginUtil.java" target-dir="src/plugin/google/maps" />
<source-file src="src/android/plugin/google/maps/PluginLatLngBounds.java" target-dir="src/plugin/google/maps" />

<config-file target="AndroidManifest.xml" parent="/manifest/application">
<meta-data
Expand Down Expand Up @@ -101,8 +100,6 @@
<source-file src="src/ios/GoogleMaps/GoogleMapsViewController.m" />
<header-file src="src/ios/GoogleMaps/GroundOverlay.h" />
<source-file src="src/ios/GoogleMaps/GroundOverlay.m" />
<header-file src="src/ios/GoogleMaps/LatLngBounds.h" />
<source-file src="src/ios/GoogleMaps/LatLngBounds.m" />
<header-file src="src/ios/GoogleMaps/KmlOverlay.h" />
<source-file src="src/ios/GoogleMaps/KmlOverlay.m" />
<header-file src="src/ios/GoogleMaps/Map.h" />
Expand Down
26 changes: 0 additions & 26 deletions src/android/plugin/google/maps/PluginLatLngBounds.java

This file was deleted.

17 changes: 0 additions & 17 deletions src/ios/GoogleMaps/LatLngBounds.h

This file was deleted.

45 changes: 0 additions & 45 deletions src/ios/GoogleMaps/LatLngBounds.m

This file was deleted.

28 changes: 22 additions & 6 deletions www/googlemaps-cdv-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,12 @@
* @params {Function} [callback] This callback is involved when the animation is completed.
*/
App.prototype.animateCamera = function(cameraPosition, callback) {
var self = this;
if (cameraPosition.target &&
cameraPosition.target.type === "LatLngBounds") {
cameraPosition.target = [cameraPosition.target.southwest, cameraPosition.target.northeast];
}

var self = this;
cordova.exec(function() {
if (typeof callback === "function") {
callback.call(self);
Expand All @@ -340,7 +344,10 @@
* @params {Function} [callback] This callback is involved when the animation is completed.
*/
App.prototype.moveCamera = function(cameraPosition, callback) {
var argsLength = arguments.length;
if (cameraPosition.target &&
cameraPosition.target.type === "LatLngBounds") {
cameraPosition.target = [cameraPosition.target.southwest, cameraPosition.target.northeast];
}
var self = this;
cordova.exec(function() {
if (typeof callback === "function") {
Expand Down Expand Up @@ -1258,6 +1265,11 @@
* LatLngBounds Class
*****************************************************************************/
var LatLngBounds = function() {
Object.defineProperty(this, "type", {
value: "LatLngBounds",
writable: false
});

var args = [];
if (arguments.length === 1 &&
typeof arguments[0] === "object" &&
Expand All @@ -1277,7 +1289,10 @@
LatLngBounds.prototype.southwest = null;

LatLngBounds.prototype.toString = function() {
return "[[" + this.southwest.toUrlValue() + "],[" + this.northeast.toUrlValue() + "]]";
return "[[" + this.southwest.toString() + "],[" + this.northeast.toString() + "]]";
};
LatLngBounds.prototype.toUrlValue = function(precision) {
return "[[" + this.southwest.toUrlValue(precision) + "],[" + this.northeast.toUrlValue(precision) + "]]";
};

LatLngBounds.prototype.extend = function(latLng) {
Expand All @@ -1300,8 +1315,10 @@
this[1] = this.northeast;
}
};
LatLngBounds.prototype.length = function() {
return (this.southwest && this.northeast) ? 2 : 0;
LatLngBounds.prototype.getCenter = function() {
return new LatLng(
(this.southwest.lat + this.northeast.lat) / 2,
(this.southwest.lng + this.northeast.lng) / 2);
};

LatLngBounds.prototype.contains = function(latLng) {
Expand All @@ -1310,7 +1327,6 @@
}
return (latLng.lat >= this.southwest.lat) && (latLng.lat <= this.northeast.lat) &&
(latLng.lng >= this.southwest.lng) && (latLng.lng <= this.northeast.lng);

};

/*****************************************************************************
Expand Down

0 comments on commit 84e1ed3

Please sign in to comment.