(Browser) Fix: PluginStreetViewPanorama.js is incomplete
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.4.4-beta-20180913-1458" 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.4.4-beta-20180913-1700" 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="Promise" src="www/Promise.js">
<runs/>

MODIFY
src/browser/PluginStreetViewPanorama.js
src/browser/PluginStreetViewPanorama.js
@@ -51,6 +51,7 @@ function PluginStreetViewPanorama(panoramaId, options, panoramaDivId) {
self.set("isGoogleReady", true);
var service = new google.maps.StreetViewService();
+ self.set('service', service);
new Promise(function(resolve, reject) {
if (options.camera) {
var request = {};
@@ -102,11 +103,13 @@ function PluginStreetViewPanorama(panoramaId, options, panoramaDivId) {
pov.pitch = options.camera.tilt;
}
if ('bearing' in options.camera) {
- pov = pov | {};
+ pov = pov || {};
pov.heading = options.camera.bearing;
}
+ if (pov) {
stOptions.pov = pov;
}
+ }
google.maps.event.addDomListener(container, 'click', function(evt) {
var pov = panorama.getPov();
@@ -129,19 +132,158 @@ function PluginStreetViewPanorama(panoramaId, options, panoramaDivId) {
self.set('panorama', panorama);
self.trigger(event.PANORAMA_READY);
- panorama.addListener("pano_changed", self._onPanoChangedEvent.bind(self, panorama));
+ panorama.addListener("position_changed", self._onPanoChangedEvent.bind(self, panorama));
panorama.addListener("pov_changed", self._onCameraEvent.bind(self, panorama));
panorama.addListener("zoom_changed", self._onCameraEvent.bind(self, panorama));
});
-
});
}
utils.extend(PluginStreetViewPanorama, BaseClass);
+PluginStreetViewPanorama.prototype.setPanningGesturesEnabled = function(onSuccess, onError, args) {
+ var self = this;
+ var panorama = self.get("panorama");
+ var boolValue = args[0] === true;
+
+ if (panorama) {
+ panorama.setOptions({
+ 'panControl': boolValue
+ });
+ }
+
+ onSuccess();
+};
+
+PluginStreetViewPanorama.prototype.setZoomGesturesEnabled = function(onSuccess, onError, args) {
+ var self = this;
+ var panorama = self.get("panorama");
+ var boolValue = args[0] === true;
+
+ if (panorama) {
+ panorama.setOptions({
+ 'zoomControl': boolValue,
+ 'scrollwheel': boolValue,
+ });
+ }
+
+ onSuccess();
+};
+
+
+PluginStreetViewPanorama.prototype.setNavigationEnabled = function(onSuccess, onError, args) {
+ var self = this;
+ var panorama = self.get("panorama");
+ var boolValue = args[0] === true;
+
+ if (panorama) {
+ panorama.setOptions({
+ 'linksControl': boolValue
+ });
+ }
+
+ onSuccess();
+};
+
+PluginStreetViewPanorama.prototype.setStreetNamesEnabled = function(onSuccess, onError, args) {
+ var self = this;
+ var panorama = self.get("panorama");
+ var boolValue = args[0] === true;
+
+ if (panorama) {
+ panorama.setOptions({
+ 'addressControl': boolValue,
+ 'showRoadLabels': boolValue
+ });
+ }
+
+ onSuccess();
+};
+PluginStreetViewPanorama.prototype.setStreetNamesEnabled = function(onSuccess, onError, args) {
+ var self = this;
+ var panorama = self.get("panorama");
+ var boolValue = args[0] === true;
+
+ if (panorama) {
+ panorama.setOptions({
+ 'visible': boolValue
+ });
+ }
+
+ onSuccess();
+};
+
+PluginStreetViewPanorama.prototype.setPosition = function(onSuccess, onError, args) {
+ var self = this;
+ var panorama = self.get("panorama");
+ var camera = args[0];
+
+ if (panorama) {
+ var service = self.get('service');
+
+ new Promise(function(resolve, reject) {
+ var request = {};
+ if (typeof camera.target === "string") {
+ request.pano = camera.target;
+ } else {
+ request.location = camera.target;
+ request.radius = camera.radius | 50;
+ request.source = camera.source === "OUTDOOR" ?
+ google.maps.StreetViewSource.OUTDOOR : google.maps.StreetViewSource.DEFAULT;
+ }
+ var timeoutError = setTimeout(function() {
+ reject('timeout error');
+ }, 3000);
+
+ service.getPanorama(request, function(data, status) {
+ clearTimeout(timeoutError);
+ if (status === google.maps.StreetViewStatus.OK) {
+ resolve(data.location.pano);
+ } else {
+ reject();
+ }
+ });
+ })
+ .then(function(panoId) {
+ panorama.setPano(panoId);
+ onSuccess();
+ })
+ .catch(onError);
+ } else {
+ onError('panorama has been already removed.');
+ }
+
+};
+
+PluginStreetViewPanorama.prototype.setPov = function(onSuccess, onError, args) {
+ var self = this;
+ var panorama = self.get("panorama");
+ var povRequest = args[0];
+
+ if (panorama) {
+ var options = {};
+ if ('bearing' in povRequest) {
+ options.pov = {};
+ options.pov.heading = povRequest.bearing;
+ }
+ if ('tilt' in povRequest) {
+ options.pov = options.pov || {};
+ options.pov.pitch = povRequest.tilt;
+ }
+ if ('zoom' in povRequest) {
+ options.zoom = povRequest.zoom;
+ }
+ panorama.setOptions(options);
+ }
+
+ onSuccess();
+};
+
+
+
PluginStreetViewPanorama.prototype._onCameraEvent = function(panorama) {
var self = this;
var pov = panorama.getPov();
@@ -170,13 +312,15 @@ PluginStreetViewPanorama.prototype._onPanoChangedEvent = function(panorama) {
}
};
- var links = panorama.getLinks();
+ var links = panorama.getLinks() || [];
+ if (links) {
locationInfo.links = links.map(function(link) {
return {
'panoId': link.pano,
'bearing': link.heading
};
});
+ }
if (self.id in plugin.google.maps) {
plugin.google.maps[self.id]({
'evtName': event.PANORAMA_LOCATION_CHANGE,

(Browser) Fix: PluginStreetViewPanorama.js is incomplete