Based on https://forge.autodesk.com/blog/iphone-panorama-forge-viewer example, I am able to use panorama on my iphone. However, when I tried to implement this extension using Forge Viewer v6, it does not work.
How do I implement this feature in v6?
Due to some changes between the versions, the process of overriding the Gamepad behavior is now a little different:
In your HTML, include a <script> tag with the FirstPerson extension, and follow it by another <script> tag with the deviceOrientationExt extension:
<head>
...
<script src="https://developer.api.autodesk.com/modelderivative/v2/viewers/viewer3D.min.js?v=v6.0"></script>
...
<script src="https://developer.api.autodesk.com/modelderivative/v2/viewers/extensions/FirstPerson/FirstPerson.js?v=v6.0"></script>
<script src="https://raw.githubusercontent.com/wallabyway/deviceOrientationExt/master/docs/deviceOrientationExt.js"></script>
</head>
And in your JavaScript code, activate the first person tool after loading the FirstPerson extension:
viewer.loadExtension('Autodesk.FirstPerson').then(function() {
viewer.toolController.activateTool('firstperson');
});
Related
I have a Chrome Extension that worked great with the background specified as a script (background.js). Chrome created a virtual background.html page...
I need to a script to background (to get Google Drive integration) and so (as I understand it) need to move to background.html.
My Manifest now specifies:
"background": {
"page": "background.html"},
I added "https://apis.google.com/js/api.js" to my original setup (below) to gain Google Drive access for my Chrome Extension...but my background page was throwing "gapi is not defined" errors...so I switched to background.html to try and get my background processes to be able to access the Drive scripts.
"background": {
"scripts": ["/dscripts/jquery-3.1.1.min.js","/dscripts/firebase.js","/dscripts/bootstrap-multiselect.min.js","/dscripts/bootstrap.min.js", "https://apis.google.com/js/api.js", "/scripts/background.js"]},
My new background.html page looks like:
<!DOCTYPE html>
<html>
<head>
<!--Original javascript / CDN -->
<script type="text/javascript" src="dscripts/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="dscripts/jquery-ui.min.js"></script>
<script type="text/javascript" src="dscripts/bootstrap.min.js"></script>
<script type="text/javascript" src="dscripts/bootstrap-toggle.min.js"></script>
<!-- FIREBASE - I think we only need JS, not app.js and auth.js -->
<script src="dscripts/firebase.js"></script>
<!-- <script src="https://www.gstatic.com/firebasejs/4.6.2/firebase.js"></script>
<script> -->
<!-- Google APIS -->
<script type="text/javascript" src="https://apis.google.com/js/api.js"></script>
<!-- background.js -->
<script type="text/javascript" src="scripts/background.js">
</head>
</html>
I haven't made any changes to background.js - which holds chrome.runtime.onStartup.addListener and lots of well-established logic.
When I run my Extension and view the background.html console, I get:
Navigated to chrome-extension://XXXXX/background.html
Usually there would be a ton of debug console content generated by my background.js file. It's as if the background.js doesn't run.
Which makes sense, I guess - there's no dom to load and trigger actions.
I feel like I'm missing something really obvious (apologies) - but all the examples I could find use background.js, not background.html.
How do I get my javascript to fire when specifying background.html?
Was missing closing tag on the background.js file. Once I added that then the js in background ran exactly as expected.
So there is no extra action (for those coming after) required to use your own background.html page vs. the auto-generated one.
According to http://blog.teamtreehouse.com/introduction-html-imports
To enable HTML imports in Chrome, go to chrome://flags and enable the Enable HTML Imports flag. Once you’re done, click the Relaunch Now button at the bottom of the screen to restart Chrome with support for HTML imports.
But I can't find it in latest version of Google Chrome flags
HTML Imports are implemented natively in Chrome, Opera and Android.
It is still a W3C Working Draft.
For other browsers, you can use:
the webcomponentsjs polyfill,
or directly the file html-imports.min.js from HTML Imports.
Update 2019
HTML Imports won't be supported natively after Chrome 73. You should then use another solutions:
the polyfill,
an alternate module loader,
JS import combined with template literals,
a direct download with fetch().
Update 2020
HTML Imports were definitvely removed.
I found an alternate way to do the same. I put the whole file to be imported,in a string,
then call document.write(theString) .for example
//head.js
var s=
`<meta charset='UTF-8'>
<link rel="stylesheet" href="/Program/assets/css/main.css">
<script src="/Program/assets/js/my.js"></script>
<script src="/Program/libs/highlight/highlight.pack.js"></script>
<link rel='stylesheet' href='/Program/libs/highlight/androidstudio2.css'>
<script src='/Program/assets/js/jquery.3.4.1.js' ></script>
<script>
$('code').each(function() {
var that = $(this);
var html = that.html().trim();
that.empty();
that.text(html);
});
hljs.initHighlightingOnLoad();
</script>
`;
document.write(s);
then I call this newly created script file instead of the main file:
<script src="/Program/head.js"></script>
Just wondering if anyone had done this before, i have used the code that yammer provide in order to embed a certain group or page into an application, here is my class file below:
<ion-view view-title="Feed">
<ion-content>
<body>
<div id="embedded-feed" style="height:200px;width:100px;"></div>
<script type="text/javascript" src="https://assets.yammer.com/assets/platform_embed.js"></script>
<script type="text/javascript"> yam.connect.embedFeed({
container: "#embedded-feed",
network: "MyGroup.com",
feedType: "group",
feedId: "111111"});
</script>
</body>
</ion-content>
</ion-view>
when i run the page in a browser it shows fine, yet nothing shows when ran on an ios simulator.
Any help is appriciated,
thanks.
You probably need to add https://assets.yammer.com (or maybe even *.yammer.com) to the whitelisted urls in the cordova container, otherwise all communications will be blocked.
yammer embedded-feed is not possible in cordova hybrid app. Use REST APIs to get the message/ feed .
I have seen similar posts before, but none of the solutions I have seen online seem to work for me.
I am trying to use a WebBrowser Control to display a locally saved HTML file that uses the Google Maps JavaScript API, but JavaScript remains stubbornly disabled.
To test the problem, I made a simple page using Google Maps based on https://developers.google.com/maps/documentation/javascript/examples/map-simple . I also added a button to directly test if JavaScript was functioning
c:\map-test.html works perfectly in both Firefox and IE.
<!DOCTYPE html>
<html>
<head>
<title>Google Maps JavaScript API v3 Example: Map Simple</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body, #map_canvas {
margin: 0;
padding: 0;
height: 100%;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
var map;
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<input type="button" onclick="alert('JavaScript Functioning');" value="Test JavaScript">
<div id="map_canvas"></div>
</body>
</html>
I then created an MS Access form with a WebBrowser Control named cWebBrowser and added a method to load c:\map-test.html. The Google Maps interface doesn't load and the test button is dead.
Private Sub Form_Current()
Me.cWebBrowser.ControlSource = "=(""file:///C:/map-test.html"")"
End Sub
Next, I tried the online version of map-simple. The JavaScript worked as expected and the Google Map interface loaded
Private Sub Form_Current()
Me.cWebBrowser.ControlSource = "=(""https://google-developers.appspot.com/maps/documentation/javascript/examples/map-simple"")"
End Sub
I have been trying to solve this problem for quite a while without success.
Following this article, http://support.microsoft.com/?kbid=315933 , I enabled the My Computer Zone in IE security settings
In all zones I enabled the following:
Allow scripting of Microsoft web browser control
Active Scripting
Under the Advanced Tab I enabled the following:
Allow active content from CDs to run on My Computer
Allow active content to run in files on My Computer
Someone suggested adding Mark of the Web to my pages, but that didn't help either.
I have tried clearing the cache.
I have tried changing the filename, in case the cache remained after clearing.
map-test.html works when downloaded in both IE and the WebBrowser Control but only works locally using IE. What else could be causing the problem other than a security setting? Is there a security setting that I am missing? Is there any other test that I could do to diagnose the problem?
I'm at my wits end.
Environment:
Windows 7 64bit
Access 2010
IE 9
P.S.
The problem continues to get weirder
Today, I tried creating an extremely simple JavaScript page to ensure it wasn't the Google Maps code causing the problem.
<!DOCTYPE html>
<html>
<body>
<input type="button" onclick="alert('JavaScript Functioning');" value="Test JavaScript">
</body>
</html>
It worked at first and I was elated. Next, I tried the Google Maps test page and that worked too! So, I tried my full-featured map (working in IE and Firefox) that loads JSON output from my DB application and it all went down in flames, Google Maps code internally caused numerous errors (unfortunately, I didn't document the errors).
Now, I'm back at square one; none of the pages allow scripting, including the 5 liner above ?!?!
First, have a look at Enhanced Protected Mode and Local Files and Understanding Local Machine Zone Lockdown.
What works on my machine
I've tested different configurations, using your exact same environment, and they all work (see caveats below).
Created a new form, add a webbrowser control to it then:
Set its ControlSource to the URL works:
Download the HTML and save it to my desktop, then reference the local file in the ControlSource works:
Added a button and set the Webbrowser's ControlSource within its OnClick event works:
Private Sub Command1_Click()
WebBrowser0.ControlSource = "=""C:\Users\Renaud\Desktop\map-simple.htm"""
End Sub
Solutions
From the links to the articles about local webpage security I mentioned above, I tried a few things:
If the file in saved in the user's temp folder, it will load properly.
Try it, type %TEMP% in Explorer and it should take you to C:\Users\username\AppData\Local\Temp or something equivalent.
Save the html file there and try to load it from Access, for instance using the button on the form above:
Private Sub Command1_Click()
WebBrowser0.ControlSource = "=""C:\Users\Renaud\AppData\Local\Temp\map-simple.htm"""
End Sub
Alternatively, for IE to allow you to open the file, you would need to lower its integrity level so it is forced to run in the Internet zone when IE opens it (and thus make it work properly).
You can check the current settings for the file by opening the command prompt (as Administrator):
Now, we can set the file Integrity and check the settings again:
Now you should be able to open the file from Access and IE.
Note though that the ACLs travel with the file when you move them from NTFS system to another NTFS system, but they could be lost if you copy them to a USB flashdrive or another system formatted as FAT for instance, so they may need to be re-applied on the target machine if they are lost.
I tried to add a Mark Of The Web to the file itself, as Remou mentioned, but it doesn't work for me, the file won't load.
Here is what I tried:
<!doctype html>
<!-- saved from url=(0014)about:internet -->
<html>
<head>
<title>Google Maps JavaScript API v3 Example: Map Simple</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
....
One other thing that should work is to try to serve the files from a local http server, like Mongoose
What works on my machine
Purely for the sake of future readers.
Using Windows 7 and Access 2010 and the Webbrowser Control from the toolbar, not from the additional ActiveX controls; using the code (below) from the OP and adding Mark of the Web (MOTW); using a *.html document saved to desktop; setting webbrowser control source to ="C:\Users\<user>\Desktop\java.htm".
<!DOCTYPE html>
<!-- saved from url=(0023)http://www.contoso.com/ -->
<html>
<head>
<title>Google Maps JavaScript API v3 Example: Map Simple</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body, #map_canvas {
margin: 0;
padding: 0;
height: 100%;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
var map;
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<input type="button" onclick="alert('JavaScript Functioning');" value="Test JavaScript">
<div id="map_canvas"></div>
</body>
</html>
I've used the WebBrowser Control many times on Access forms, with locally-generated content.
For portability, I don't want to mess with the security settings on each computer.
My solution is to use VBA instead of Javascript, for anything run locally. You can even attach VBA-based event handlers to document elements. (Use Object Browser to explore the MSHTML library.)
This includes both files loaded with file:// and on pages built by navigating to about:blank and then writing content with WebBrowser.Document.Open / .Write.
For Google Maps, you should be able to build a local document that hosts an Internet-based iframe.
Security-wise, Javascript won't work in the local document but it should work in the iframe.
...Tom Robinson
I use google map's api in my website to show couple of locations. Google Maps is working just fine in my local solution but not in my website. I changed this source
<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3.5&sensor=false"> </script>
to this one. and i again changed this
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"> </script>
with this one...
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"> </script>
Only thing it says: ReferenceError: google is not defined
Does anyone familiar with such problem?
Owing to the fact that my website uses https for the connection, I can not use http://maps.google.com/maps/api/js?sensor=false. When I debug the whole page, this link says: Warning : The page index.html ran insecure content. so I made another search on google and came across to this question. so what basically causes a problem is not using https link in the source part so the correct link will be (for me)
https://maps.google.com/maps/api/js?sensor=false
now everything works just fine!
That's an old URL. If you look at the examples from the documentation, almost all of them use:
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
To me, with the new Google Maps API, simply this solution worked:
Just omit "async defer" from the script provided by goolge:
<script async defer src="https://maps.googleapis.com/maps/api/js?key={your_key}"></script>
TO
<script src="https://maps.googleapis.com/maps/api/js?key={your_key}"></script>
i met this problem in the rails application.
request to googlemap was from http and https pages
and it solved:
= javascript_include_tag "//maps.google.com/maps/api/js?sensor=false"
if protocol not defined rails inserts automatic