Change method names of StreetViewPanorama class
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.3.0-beta-201800508-1905" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
+<plugin id="cordova-plugin-googlemaps" version="2.3.0-beta-201800509-1823" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>cordova-plugin-googlemaps</name>
<js-module name="BaseClass" src="www/BaseClass.js">
<runs />

MODIFY
src/android/plugin/google/maps/PluginStreetViewPanorama.java
src/android/plugin/google/maps/PluginStreetViewPanorama.java
@@ -2,13 +2,9 @@ package plugin.google.maps;
import android.app.Activity;
import android.graphics.Point;
-import android.os.Handler;
-import android.os.Looper;
-import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
-import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.OnStreetViewPanoramaReadyCallback;
import com.google.android.gms.maps.StreetViewPanorama;
import com.google.android.gms.maps.StreetViewPanoramaOptions;
@@ -36,7 +32,6 @@ public class PluginStreetViewPanorama extends MyPlugin implements
StreetViewPanorama.OnStreetViewPanoramaClickListener {
private Activity mActivity;
- private Handler mainHandler;
private StreetViewPanoramaView panoramaView;
private StreetViewPanorama panorama;
private String panoramaId;
@@ -50,7 +45,6 @@ public class PluginStreetViewPanorama extends MyPlugin implements
public void initialize(CordovaInterface cordova, final CordovaWebView webView) {
super.initialize(cordova, webView);
mActivity = cordova.getActivity();
- mainHandler = new Handler(Looper.getMainLooper());
}
public int getViewDepth() {
@@ -268,29 +262,66 @@ public class PluginStreetViewPanorama extends MyPlugin implements
}
- public void moveCamera(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
+ public void setPosition(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
try {
- final JSONObject cameraPosition = args.getJSONObject(0);
- if (cameraPosition.has("target")) {
- JSONObject target = cameraPosition.getJSONObject("target");
- LatLng latLng = new LatLng(target.getDouble("lat"), target.getDouble("lng"));
- panorama.setPosition(latLng);
+ JSONObject cameraOpts = args.getJSONObject(0);
+ Object target = cameraOpts.get("target");
+
+ if (target instanceof JSONObject) {
+ JSONObject targetJson = (JSONObject)target;
+ LatLng position = new LatLng(targetJson.getDouble("lat"), targetJson.getDouble("lng"));
+
+ if (cameraOpts.has("source")) {
+ StreetViewSource source = "OUTDOOR".equals(cameraOpts.getString("source")) ?
+ StreetViewSource.OUTDOOR : StreetViewSource.DEFAULT;
+ if (cameraOpts.has("radius")) {
+ panorama.setPosition(position, cameraOpts.getInt("radius"), source);
+ } else {
+ panorama.setPosition(position, source);
+ }
+ } else {
+ if (cameraOpts.has("radius")) {
+ panorama.setPosition(position, cameraOpts.getInt("radius"));
+ } else {
+ panorama.setPosition(position);
+ }
+ }
+ } else if (target instanceof String) {
+ panorama.setPosition(cameraOpts.getString("target"));
}
+ callbackContext.success();
+ } catch (JSONException e) {
+ e.printStackTrace();
+ callbackContext.error("" + e.getMessage());
+ }
+ }
+ });
+ }
+
+ public void setPov(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
+
+ cordova.getActivity().runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+
+ try {
+ final JSONObject cameraPosition = args.getJSONObject(0);
+
if (cameraPosition.has("bearing") || cameraPosition.has("tilt")) {
StreetViewPanoramaCamera currentCamera = panorama.getPanoramaCamera();
float bearing = cameraPosition.has("bearing") ? (float) cameraPosition.getDouble("bearing") : currentCamera.bearing;
float tilt = cameraPosition.has("tilt") ? (float) cameraPosition.getDouble("tilt") : currentCamera.tilt;
float zoom = cameraPosition.has("zoom") ? (float) cameraPosition.getDouble("zoom") : currentCamera.zoom;
-
+ long duration = cameraPosition.has("duration") ? (long) cameraPosition.getDouble("duration") : 0;
StreetViewPanoramaCamera newCamera = new StreetViewPanoramaCamera(bearing, tilt, zoom);
- panorama.animateTo(newCamera, 0);
+ panorama.animateTo(newCamera, duration);
}
callbackContext.success();

MODIFY
src/ios/GoogleMaps/PluginStreetViewPanorama.h
src/ios/GoogleMaps/PluginStreetViewPanorama.h
- (void)getPanorama:(CDVInvokedUrlCommand*)command;
- (void)attachToWebView:(CDVInvokedUrlCommand*)command;
- (void)detachFromWebView:(CDVInvokedUrlCommand*)command;
-- (void)moveCamera:(CDVInvokedUrlCommand*)command;
+- (void)setPov:(CDVInvokedUrlCommand*)command;
+- (void)setPosition:(CDVInvokedUrlCommand*)command;
- (void)setPanningGesturesEnabled:(CDVInvokedUrlCommand*)command;
- (void)setZoomGesturesEnabled:(CDVInvokedUrlCommand*)command;
- (void)setNavigationEnabled:(CDVInvokedUrlCommand*)command;

MODIFY
src/ios/GoogleMaps/PluginStreetViewPanorama.m
src/ios/GoogleMaps/PluginStreetViewPanorama.m
NSDictionary *initOptions = [command.arguments objectAtIndex:1];
if ([initOptions objectForKey:@"camera"]) {
- [self _movePanoramaCamera:[initOptions objectForKey:@"camera"]];
+ [self _setPosition:[initOptions objectForKey:@"camera"]];
+ [self _setPov:[initOptions objectForKey:@"camera"]];
}
if ([initOptions objectForKey:@"gestures"]) {
NSDictionary *gestures = [initOptions objectForKey:@"gestures"];
}
-- (void)moveCamera:(CDVInvokedUrlCommand *)command {
+- (void)setPov:(CDVInvokedUrlCommand *)command {
[self.panoramaCtrl.executeQueue addOperationWithBlock:^{
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
NSDictionary *cameraOpts = [command.arguments objectAtIndex:0];
- [self _movePanoramaCamera:cameraOpts];
+ [self _setPov:cameraOpts];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}
-- (void)_movePanoramaCamera:(NSDictionary *)cameraOpts {
+- (void)setPosition:(CDVInvokedUrlCommand *)command {
+ [self.panoramaCtrl.executeQueue addOperationWithBlock:^{
+ [[NSOperationQueue mainQueue] addOperationWithBlock:^{
+ NSDictionary *cameraOpts = [command.arguments objectAtIndex:0];
+ [self _setPosition:cameraOpts];
+
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+ }];
+ }];
+}
+- (void)_setPosition:(NSDictionary *)cameraOpts {
if ([cameraOpts valueForKey:@"target"]) {
NSObject *target = [cameraOpts objectForKey:@"target"];
}
+}
+
+- (void)_setPov:(NSDictionary *)cameraOpts {
+
+
double bearing = self.panoramaCtrl.panoramaView.camera.orientation.heading;
if ([cameraOpts valueForKey:@"bearing"]) {
bearing = [[cameraOpts valueForKey:@"bearing"] doubleValue];

MODIFY
www/StreetViewPanorama.js
www/StreetViewPanorama.js
@@ -203,41 +203,52 @@ StreetViewPanorama.prototype.getLinks = function () {
StreetViewPanorama.prototype.getLocation = function () {
return this.get('location');
};
-StreetViewPanorama.prototype.getPano = function () {
+StreetViewPanorama.prototype.getPanoId = function () {
return this.get('pano');
};
StreetViewPanorama.prototype.getPosition = function () {
return this.get('position');
};
-StreetViewPanorama.prototype.moveCamera = function(cameraPosition, callback) {
+StreetViewPanorama.prototype.setPosition = function(cameraPosition, callback) {
var self = this;
cameraPosition = cameraPosition || {};
- cameraPosition.duration = 0;
- self.animateCamera.call(self, cameraPosition, callback);
+ if (typeof cameraPosition.target === "object") {
+ self.set("position", cameraPosition.target);
+ }
+ self.exec.call(self, function() {
+ if (typeof callback === "function") {
+ callback.call(self);
+ }
+ }, self.errorHandler, self.id, 'setPosition', [cameraPosition], {
+ sync: true
+ });
return this;
};
-StreetViewPanorama.prototype.animateCamera = function(cameraPosition, callback) {
+StreetViewPanorama.prototype.setPov = function(pov, callback) {
var self = this;
- cameraPosition = cameraPosition || {};
- if (typeof cameraPosition.target === "object") {
- self.set("position", cameraPosition.target);
- }
+ pov = pov || {};
if ("zoom" in cameraPosition) {
self.set("camera_zoom", cameraPosition.zoom);
+ } else {
+ pov.zoom = self.get("camera_zoom");
}
if ("bearing" in cameraPosition) {
self.set("camera_bearing", cameraPosition.bearing);
+ } else {
+ pov.bearing = self.get("camera_bearing");
}
if ("tilt" in cameraPosition) {
self.set("camera_tilt", cameraPosition.tilt);
+ } else {
+ pov.tilt = self.get("camera_tilt");
}
self.exec.call(self, function() {
if (typeof callback === "function") {
callback.call(self);
}
- }, self.errorHandler, self.id, 'moveCamera', [cameraPosition], {
+ }, self.errorHandler, self.id, 'setPov', [cameraPosition], {
sync: true
});
return this;

MODIFY
www/googlemaps-cdv-plugin.js
www/googlemaps-cdv-plugin.js
@@ -68,7 +68,7 @@ if (!cordova) {
}
if (changes) {
scrollEndTimer = setTimeout(followMaps.bind(this, evt), 100);
- } else if (evt && evt.type === "scroll") {
+ } else {
common.nextTick(onTransitionEnd);
}
}

Change method names of StreetViewPanorama class