dynamic content in kml balloon from url - kml

I have a server that is serving up an xhtml page with all of the content I want displayed in my google earth (or worldwind) balloon. I would like the placemark balloon to fetch the html page when it is clicked on the map. To make it simple, I want my balloon to be www.yahoo.com when you click it from the map.
Any searching online sends me to java code that can hook into the google earth api. I am really hoping there is a client side kml way to do this. Is there an extended data tag or description tag I can use to get this to work? I have even tried to use the embed tag which works great for a you tube video but there is no plugin for an html page. Any help is much appreciated.
This works too but an iframe is pretty ugly -
<Placemark>
<name>Test Placemark</name>
<description>
<![CDATA[
<iframe src="http://www.yahoo.com" frameborder="0"
scrolling="auto" height="500" width="600"></iframe>
]]>
</description>
...

you could try the getBalloonHtmlUnsafe() and the HtmlDivBalloon? https://developers.google.com/earth/documentation/balloons#getballoonhtmlunsafe
However you are adding the kml to the page you could then bind a click function to those placemarks.
google.earth.fetchKml(ge, url, function(kmlObject){
if(kmlObject){
ge.getFeatures().appendChild(kmlObject);
if(kmlObject.getType() === 'KmlPlacemark'){
google.earth.addEventListener(kmlObject, 'click', function(event){
event.preventDefault();
var balloon = ge.createHtmlDivBalloon('');
var content = kmlObject.getBalloonHtmlUnsafe();
balloon.setFeature(kmlObject);
var div = document.createElement('div');
div.innerHTML = content;
balloon.setContentDiv(div);
ge.setBalloon(balloon);
});
}
}
});
If that still doesn't work, remember that google earth scrubs a lot of balloon data so you might try using jquery to inject the html.
var balloon = ge.createHtmlDivBalloon('');
var content = kmlObject.getBalloonHtmlUnsafe();
balloon.setFeature(kmlObject);
var div = document.createElement('div');
balloon.setContentDiv(div);
ge.setBalloon(balloon);
$(div).html(content);

Related

How to embed YouTube videos to the website without using iframes? [duplicate]

Is it possible to embed an html5 version of a youtube video without using an iframe?
Here is a example of embedding without an iFrame:
<div style="width: 560px; height: 315px; float: none; clear: both; margin: 2px auto;">
<embed
src="https://www.youtube.com/embed/J---aiyznGQ?autohide=1&autoplay=1"
wmode="transparent"
type="video/mp4"
width="100%" height="100%"
allow="autoplay; encrypted-media; picture-in-picture"
allowfullscreen
title="Keyboard Cat"
>
</div>
compare to regular iframe "embed" code from YouTube:
<iframe
width="560"
height="315"
src="https://www.youtube.com/embed/J---aiyznGQ?autoplay=1"
frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen>
</iframe>
and as far as HTML5 goes, use <object> tag like so (corrected):
<object
style="width: 820px; height: 461.25px; float: none; clear: both; margin: 2px auto;"
data="http://www.youtube.com/embed/J---aiyznGQ?autoplay=1">
</object>
Yes. Youtube API is the best resource for this.
There are 3 way to embed a video:
IFrame embeds using <iframe> tags
IFrame embeds using the IFrame Player API
AS3 (and AS2*) object embeds DEPRECATED
I think you are looking for the second one of them:
IFrame embeds using the IFrame Player API
The HTML and JavaScript code below shows a simple example that inserts a YouTube player into the page element that has an id value of ytplayer. The onYouTubePlayerAPIReady() function specified here is called automatically when the IFrame Player API code has loaded. This code does not define any player parameters and also does not define other event handlers.
<div id="ytplayer"></div>
<script>
// Load the IFrame Player API code asynchronously.
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
// Replace the 'ytplayer' element with an <iframe> and
// YouTube player after the API code downloads.
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('ytplayer', {
height: '390',
width: '640',
videoId: 'M7lc1UVf-VE'
});
}
</script>
Here are some instructions where you may take a look when starting using the API.
An embed example without using iframe is to use <object> tag:
<object width="640" height="360">
<param name="movie" value="http://www.youtube.com/embed/yt-video-id?html5=1&rel=0&hl=en_US&version=3"/
<param name="allowFullScreen" value="true"/>
<param name="allowscriptaccess" value="always"/>
<embed width="640" height="360" src="http://www.youtube.com/embed/yt-video-id?html5=1&rel=0&hl=en_US&version=3" class="youtube-player" type="text/html" allowscriptaccess="always" allowfullscreen="true"/>
</object>
(replace yt-video-id with your video id)
JSFIDDLE
Because of the GDPR it makes no sense to use the iframe, you should rather use the object tag with the embed tag and also use the embed link.
<object width="100%" height="333">
<param name="movie" value="https://www.youtube-nocookie.com/embed/Sdg0ef2PpBw">
<embed src="https://www.youtube-nocookie.com/embed/Sdg0ef2PpBw" width="100%" height="333">
</object>
You should also activate the extended data protection mode function to receive the no cookie url.
type="application/x-shockwave-flash"
flash does not have to be used
Nocookie, however, means that data is still being transmitted, namely the thumbnail that is loaded from YouTube. But at least data is no longer passed on to advertising networks (as example DoubleClick). And no user data is stored on your website by youtube.
Yes, but it depends on what you mean by 'embed'; as far as I can tell after reading through the docs, it seems like you have a couple of options if you want to get around using the iframe API. You can use the javascript and flash API's (https://developers.google.com/youtube/player_parameters) to embed a player, but that involves creating Flash objects in your code (something I personally avoid, but not necessarily something that you have to). Below are some helpful sections from the dev docs for the Youtube API.
If you really want to get around all these methods and include video without any sort of iframe, then your best bet might be creating an HTML5 video player/app that can connect to the Youtube Data API (https://developers.google.com/youtube/v3/). I'm not sure what the extent of your needs are, but this would be the way to go if you really want to get around using any iframes or flash objects.
Hope this helps!
Useful:
(https://developers.google.com/youtube/player_parameters)
IFrame embeds using the IFrame Player API
Follow the IFrame Player API instructions to insert a video player in your web page or application after the Player API's JavaScript code has loaded. The second parameter in the constructor for the video player is an object that specifies player options. Within that object, the playerVars property identifies player parameters.
The HTML and JavaScript code below shows a simple example that inserts a YouTube player into the page element that has an id value of ytplayer. The onYouTubePlayerAPIReady() function specified here is called automatically when the IFrame Player API code has loaded. This code does not define any player parameters and also does not define other event handlers.
...
IFrame embeds using tags
Define an tag in your application in which the src URL specifies the content that the player will load as well as any other player parameters you want to set. The tag's height and width parameters specify the dimensions of the player.
If you are creating the element yourself (rather than using the IFrame Player API to create it), you can append player parameters directly to the end of the URL. The URL has the following format:
...
AS3 object embeds
Object embeds use an tag to specify the player's dimensions and parameters. The sample code below demonstrates how to use an object embed to load an AS3 player that automatically plays the same video as the previous two examples.
Use the object tag:
<object data="http://iamawesome.com" type="text/html" width="200" height="200">
access the page directly
</object>
Ref: http://debug.ga/embedding-external-pages-without-iframes/

Full Calendar Events not working

I have written fullcalendar code in one HTML file and want to use it in other HTML file in div tag, I did this by calling javascript function in which I set the innerHTML of div tag to object tag like:
document.getElementById("content").innerHTML = '<object class="preventScroll" id="calObj" type="text/html" data="Calendar.html" height="100%" width="100%" align="left"></object>';
It is rendering the calendar in div with id "content" but the dayclick and eventclick are not working
i guess you should try and add it as an dependent object rather than rendering it as html.
e.g:
document.getElementById("content").appendChild(calendarObject)
You loose the event binding because you are rendering an html and not "live" object

How can I embedd this in my site?

Right here, there is a website with a Google maps file of the international space stations current location.
http://n2yo.com/satellite/?s=25544
How can I embed this in a standard HTML page?
Using your browser, you can right-click on the HTML element and select "Inspect Element" to see the underlying HTML and copy it into your HTML. In this case, if you include the following HTML, this should embed the map in your website.
<script language="JavaScript">
var sid=25544;
var width=400;
var height=250;
</script>
<script type="text/javascript" src="http://www.n2yo.com/js/widget.js?r=joo9"></script>
In the n2yo website they explain how to embed a satellite to your site:
http://www.n2yo.com/widgets/
This is the code you should embed:
<script src="//www.gmodules.com/ig/ifr?url=http://www.n2yo.com/sat/iss.xml&synd=open&w=320&h=200&title=The+International+Space+Station+Tracker&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js"></script>
An example on jsfiddle
You can add more customizations to the map here

Google Earth Plugin: Browsers other than FF show HTML markup when using .getBalloonHTML() to dump placemark contents into a DIV

I'm trying to dump Google Earth placemark content into a div outside the plugin, and it works as expected in FireFox, but not in Chrome, Safari, or IE. The later 3 display:
<!--Content-type: mhtml-die-die-die-->
at the beginning of the placemark contents and the HTML markup is shown with the other contents. FF parses the contents as actual HTML and so it displays correctly formatted as expected.
Would anybody know how to get the other browsers to parse the content as HTML as opposed to whatever they are doing right now?
The following is my GE plugin code:
currentKmlObject = kmlObject;
ge.getFeatures().appendChild(currentKmlObject);
google.earth.addEventListener(kmlObject, 'click', function(event) {
event.preventDefault();
var placemark = event.getTarget();
var content = placemark.getBalloonHtml();
document.getElementById('balloonContents').innerHTML = content;
document.getElementById('balloonContents').innerText = content;
I am using fetchKml to load the KML data from another URL which is setup as follows:
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document>
<Placemark>
<name></name>
<description>
<![CDATA[ HTML CONTENTS ]]>
</description>
<Point>
<coordinates></coordinates>
</Point>
</Placemark>
</Document></kml>
Many thanks in advance.
I figured it out. It has nothing to do with Google Earth or KML. For some reason I accidently assigned the placemark conntent to innerText. I only needed to assign it to innerHTML.

changing the content of browser in XULRunner

I have an Xulrunner app that loads fullscreen without any controls and loads a html page by default. The only thing it has is browser element and a popup menu visible on right click.
In the popup menu there is option to quit. Then there is a menu entry 'theme2'. I want the browser to load another html when theme2 is clicked.
This is my main.xul, thats loaded by default:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="main" title="Edusoft" hidechrome="true" sizemode="maximized" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript">
function do()
{
var browser1 = document.getElementById('browser');
browser1.loadURI("chrome://myapp/content/theme2/home.html");
}
</script>
<browser id="browser" type="content" src="chrome://myapp/content/theme1/index.html" flex="1" context="clipmenu"/>
<popupset>
<menupopup id="clipmenu">
<menuitem label="About Us"/>
<menuseparator/>
<menuitem label="Theme2" oncommand="do();"/>
<menuseparator/>
<menuitem label="Exit" oncommand="close();"/>
</menupopup>
</popupset>
</window>
I tried this, but when the page is loaded this way.. the popup menu is nomore in the new page.
window.location.assign()
There is something like loaduri(), but i have no idea on how to use it.
Ok I figured it out.
document.getElementById('browser').loadURI('chrome://myapp/content/flash/demo.htm')

Resources