Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a couple of images that I want to add to a placemark. The problem is when I add the multiple images, google earth displays them one below the other. Is it possible that the image are displayed side by side whenever I click the placemark icon.

And If there a dozen of images for the same placemark can I create a "slideshow" of the imagery that displays only one image at a time and swaps when user clicks the placemark button again?

Any help is appreciated. Thank you.

share|improve this question
add comment

3 Answers 3

If you have your images upload to a picasa (google) account you can create a slideshow for each location.

For Example - will only work in Google Earth. http://www.truenorthgis.net/test/digby_nova_scotia.kml will show a slide show in the placemarkers

enter image description here

The code to add this:(only a snippet of full kml)

<Placemark>
    <name>Digby, Nova Scotia</name>
    <Snippet maxLines="0"></Snippet>
    <description><![CDATA[<embed type="application/x-shockwave-flash" src="http://picasaweb.google.com/s/c/bin/slideshow.swf" width="800" height="533" flashvars="host=picasaweb.google.com&hl=en_US&feat=flashalbum&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fstillinorbit%2Falbumid%2F5380434143514463809%3Falt%3Drss%26kind%3Dphoto%26hl%3Den_US" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>]]></description>

You will need to change the flashvar=http://picasaweb.google.com/s/c/bin/slideshow.swf" width="800" height="533" flashvars="host=picasaweb.google.com&hl=en_US&feat=flashalbum&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fstillinorbit%2Falbumid%2F5380434143514463809%3Falt%3Drss%26kind%3Dphoto%26hl%3Den_US to your own picasa url.

share|improve this answer
    
Thanks man! appreciate it! –  Akd Jun 22 '12 at 17:58
    
Is there is way to create the slideshow without using picasa web album?..I mean using certain images in my computer. –  Akd Jun 22 '12 at 18:31
    
images need to be on the web for google earth to read. –  Mapperz Jun 22 '12 at 18:42
    
sorry I meant I already have images on a webpage( I know all urls for the images). I was looking for a kml code that can pick those images for me and create a slideshow. Is it possible without uploading them on picasa? –  Akd Jun 22 '12 at 21:23
add comment
<html>
<head>
</head>
<body>
<div id="slideshow" style="width:400px;overflow:hidden;">
    <div id="slideshowimage" style="height:300px;width:400px;overflow:hidden;"></div>
        <div id="slideshowcontrols" style="width:400px;overflow:hidden;">
            <a onClick="changeimage(-1);">Prev</a>
            <a onClick="changeimage(1);">Next</a>
        </div>
    </div>

<script type="text/javascript">
var images = new Array;
images[1] = "http://www.example.com/Chrysanthemum.jpg";
images[2] = "http://www.example.com/Desert.jpg";
images[3] = "http://www.example.com/Hydrangeas.jpg";
images[4] = "http://www.example.com/Jellyfish.jpg";
images[5] = "http://www.example.com/Tulips.jpg";
var currentimage = 1;
function changeimage(change){
   currentimage += change;
   if(currentimage > images.length - 1){
      currentimage = 1;
   }
   else if(currentimage < 1){
      currentimage = images.length - 1;
   }
   document.getElementById('slideshowimage').innerHTML = '<img id="image" width="' + document.getElementById('slideshowimage').style.width +'" src="' + images[currentimage] + '"/>';
   waitimage();
}
function waitimage(){
   if(document.getElementById('image').complete){
      positioningimage();
      return;
   }
   setTimeout('waitimage()',10);
}
function positioningimage(){
   document.getElementById('image').style.marginTop = (parseInt(document.getElementById('slideshowimage').style.height) - document.getElementById('image').height) / 2 + 'px';
}
changeimage(0);
</script>

</body>
</html>
share|improve this answer
    
I am sorry I am quite new to this field. Can you specify how can I use this code.It seems to be javascript. Can I just use it for the kml code? I tried this but of no use. –  Akd Jun 22 '12 at 23:00
add comment

I wanted to do the same thing, I can share with you a solution that worked, but it's very cludgy.

The problem with testingme's answer is that the url of the images is stored in JavaScript and Google Earth will block this content, so I needed a solution that loaded all the images and used only JavaScript no jQuery for scrolling through them.

I copied the horizontal slider code available at dyn-web.com: http://www.dyn-web.com/code/glide-scroll/ then modified it to bring everything in-line so that it could be placed within the tags.

I'm sure this can be optimized (when zipped into kmz this adds 5kb per placemark to the size of the file...) but here is my first pass at it:

<description><![CDATA[

<style type="text/css">
div#wn  { 
position:relative; /* scroll area div must be positioned */
width:616px; height:447px; /* width and height required. adjust to suit  */
overflow:hidden; /* required! */
}
div#lyr1 {
white-space:nowrap; /* content will wrap without this */
}
div#lyr1 img {
padding: 0 8px; /* optional gap between images */
}
div#scrollLinks {
position:relative;
width:616px; 
}
div#scrollLinks .left {
width:40px; height:24px;
position:absolute; left:30px;
}
div#scrollLinks .right {
width:40px; height:24px;
position:absolute; right:30px;
}
</style>
<!-- NOTE: line breaks between images will throw of calcs (for padding, width of wn, distance to glide onclick) -->
<div id="wn"> <!-- scroll area div. lyr1 is layer in scroll area (content div) -->
<div id="lyr1"><img src="http://www.example.com/image1.jpg" width="600px" height="447px" alt="" /><img src="http://www.example.com/image2.jpg" width="600px" height="447px" alt="" /><img src="http://www.example.com/image3.jpg" width="600px" height="447px" alt="" /><img src="http://www.example.com/image4.jpg" width="600px" height="447px" alt="" /><img src="http://www.example.com/image5.jpg" width="600px" height="447px" alt="" /></div> <!-- end content div (lyr1) -->
</div>  <!-- end wn div -->

<!-- Ended up using <span> to display on google earth iPad -->
<div id="scrollLinks"><span class="left">Prev</span><spanclass="right">Next</span></div> 

<script type="text/javascript">
var DYN_WEB = DYN_WEB || {};
DYN_WEB.Event=(function(Ev){Ev.add=document.addEventListener?function(obj,etype,fp,cap){cap=cap||false;obj.addEventListener(etype,fp,cap);}:function(obj,etype,fp){obj.attachEvent('on'+etype,fp);};Ev.remove=document.removeEventListener?function(obj,etype,fp,cap){cap=cap||false;obj.removeEventListener(etype,fp,cap);}:function(obj,etype,fp){obj.detachEvent('on'+etype,fp);};Ev.DOMit=function(e){e=e?e:window.event;if(!e.target){e.target=e.srcElement;}if(!e.preventDefault){e.preventDefault=function(){e.returnValue=false;return false;};}if(!e.stopPropagation){e.stopPropagation=function(){e.cancelBubble=true;};}return e;};Ev.getTarget=function(e){e=Ev.DOMit(e);var tgt=e.target;if(tgt.nodeType!==1){tgt=tgt.parentNode;}return tgt;};Ev.domReady=(function(){var funcs=[];var ready=false;function handler(e){if(ready){return;}if(e.type==="readystatechange"&&document.readyState!=="complete"){return;}for(var i=0,len=funcs.length;i<len;i++){funcs[i].call(document);}ready=true;funcs=[];}if(document.addEventListener){document.addEventListener("DOMContentLoaded",handler,false);document.addEventListener("readystatechange",handler,false);window.addEventListener("load",handler,false);}else if(document.attachEvent){document.attachEvent("onreadystatechange",handler);window.attachEvent("onload",handler);}return function whenReady(f){if(ready){f.call(document);}else{funcs.push(f);}};})();return Ev;})(DYN_WEB.Event||{});

DYN_WEB.Util=(function(Ut){Ut.$=function(id){return document.getElementById(id);};Ut.augment=function(Obj1,Obj2){var prop;for(prop in Obj2){if(Obj2.hasOwnProperty(prop)&&!Obj1[prop]){Obj1[prop]=Obj2[prop];}}};Ut.contained=function(oNode,oCont){if(!oNode){return false;}while((oNode=oNode.parentNode)){if(oNode===oCont){return true;}}return false;};Ut.getLayerOffsets=function(el,oCont){var left=0,top=0;if(Ut.contained(el,oCont)){do{left+=el.offsetLeft;top+=el.offsetTop;}while(((el=el.offsetParent)!==oCont));}return{x:left,y:top};};Ut.addElement=function(tag,id,cls,atts){var el=document.createElement(tag);if(id){el.id=id;}if(cls){el.className=cls;}for(var i in atts){if(atts.hasOwnProperty(i)){el.setAttribute(i,atts[i]);}}return el;};Ut.get_DelimitedClassList=function(cls){var ar=[],ctr=0;if(cls.indexOf('_')!==-1){var whitespace=/\s+/;if(!whitespace.test(cls)){ar[0]=cls;}else{var classes=cls.split(whitespace);for(var i=0,len=classes.length;i<len;i++){if(classes[i].indexOf('_')!==-1){ar[ctr++]=classes[i];}}}}return ar;};return Ut;})(DYN_WEB.Util||{});

DYN_WEB.Scroll_Div=(function(){var Ut=DYN_WEB.Util;function SDiv(wnId,lyrId){this.id=wnId;SDiv.col[this.id]=this;SDiv.ids[SDiv.ids.length]=this.id;this.load(lyrId);}SDiv.col={};SDiv.ids=[];SDiv.isSupported=function(){return!!(document.getElementById&&(document.addEventListener||document.attachEvent));};SDiv.prototype={load:function(lyrId){var lyr;if(this.lyrId){lyr=Ut.$(this.lyrId);lyr.style.visibility="hidden";}this.lyr=lyr=Ut.$(lyrId);this.lyr.style.position='absolute';this.lyrId=lyrId;this.y=0;this.x=0;this.shiftTo(0,0);this.getDims();lyr.style.visibility="visible";this.ready=true;this.on_load();},shiftTo:function(x,y){if(this.lyr&&!isNaN(x)&&!isNaN(y)){this.x=x;this.y=y;this.lyr.style.left=Math.round(x)+"px";this.lyr.style.top=Math.round(y)+"px";}},getDims:function(){var wndo=Ut.$(this.id);var lyr=Ut.$(this.lyrId);this.lyrWd=lyr.offsetWidth;this.lyrHt=lyr.offsetHeight;this.wnWd=wndo.offsetWidth;this.wnHt=wndo.offsetHeight;var w=this.lyrWd-this.wnWd;var h=this.lyrHt-this.wnHt;this.maxX=(w>0)?w:0;this.maxY=(h>0)?h:0;},on_load:function(){},on_scroll:function(){},on_scroll_start:function(){},on_scroll_stop:function(){},on_scroll_end:function(){},clearTimer:function(){clearInterval(this.timerId);this.timerId=0;}};return SDiv;})();

(function(){var Ut=DYN_WEB.Util,SDiv=DYN_WEB.Scroll_Div;SDiv.defaultSlideDur=500;var Glide_Scroll={initScrollByVals:function(dx,dy,dur){if(!this.ready||this.sliding){return;}this.startX=this.x;this.startY=this.y;this.destX=this.destY=this.distX=this.distY=0;if(dy<0){this.distY=(this.startY+dy>=-this.maxY)?dy:-(this.startY+this.maxY);}else if(dy>0){this.distY=(this.startY+dy<=0)?dy:-this.startY;}if(dx<0){this.distX=(this.startX+dx>=-this.maxX)?dx:-(this.startX+this.maxX);}else if(dx>0){this.distX=(this.startX+dx<=0)?dx:-this.startX;}this.destX=this.startX+this.distX;this.destY=this.startY+this.distY;this.glideScrollPrep(this.destX,this.destY,dur);},initScrollToVals:function(destX,destY,dur){if(!this.ready||this.sliding){return;}this.startX=this.x;this.startY=this.y;this.destX=-Math.max(Math.min(destX,this.maxX),0);this.destY=-Math.max(Math.min(destY,this.maxY),0);this.distY=this.destY-this.startY;this.distX=this.destX-this.startX;if(dur===0){this.on_scroll_start(this.startX,this.startY);this._jumpTo(this.destX,this.destY);}else{this.glideScrollPrep(this.destX,this.destY,dur);}},_jumpTo:function(x,y){this.shiftTo(x,y);this.on_scroll(x,y);},glideScrollPrep:function(destX,destY,dur){this.slideDur=(typeof dur==='number')?dur:SDiv.defaultSlideDur;this.per=Math.PI/(2*this.slideDur);this.sliding=true;this.lyr=Ut.$(this.lyrId);this.startTime=new Date().getTime();var self=this;self.timerId=setInterval(function(){self.doGlideScroll();},10);this.on_scroll_start(this.startX,this.startY);},doGlideScroll:function(){var elapsed=new Date().getTime()-this.startTime;if(elapsed<this.slideDur){var x=this.startX+(this.distX*Math.sin(this.per*elapsed));var y=this.startY+(this.distY*Math.sin(this.per*elapsed));this.shiftTo(x,y);this.on_scroll(x,y);}else{this.clearTimer();this.sliding=false;this.shiftTo(this.destX,this.destY);this.on_scroll(this.destX,this.destY);this.on_scroll_stop(this.destX,this.destY);if(this.distX&&(this.destX===0||this.destX===-this.maxX)||this.distY&&(this.destY===0||this.destY===-this.maxY)){this.on_scroll_end(this.destX,this.destY);}}},scrollToId:function(id,dur){var el=Ut.$(id);var lyr=Ut.$(this.lyrId);if(Ut.contained(el,lyr)){var pos=Ut.getLayerOffsets(el,lyr);this.initScrollToVals(pos.x,pos.y,dur);}}};Ut.augment(SDiv.prototype,Glide_Scroll);})();

(function(){var Ev=DYN_WEB.Event,Ut=DYN_WEB.Util,SDiv=DYN_WEB.Scroll_Div;var Glide_Scroll_Controls={addGlideControls:function(id,axis,distance,dur){var wnId=this.id,pr=(axis==='v')?wnId+'_':wnId+'_h_',self=this,controls=Ut.$(id),start_cls,end_cls,start_el,end_el,dx,dy,f=document.createDocumentFragment();if(axis==='v'){start_cls='up';end_cls='down';dx=0;dy=distance;}else{start_cls='left';end_cls='right';dx=distance;dy=0;}start_el=Ut.addElement('div',pr+start_cls,start_cls);end_el=Ut.addElement('div',pr+end_cls,end_cls);f.appendChild(start_el);f.appendChild(end_el);controls.appendChild(f);Ev.add(start_el,'click',function(e){self.initScrollByVals(dx,dy,dur);if(e&&e.preventDefault){e.preventDefault();}return false;});Ev.add(end_el,'click',function(e){self.initScrollByVals(-dx,-dy,dur);if(e&&e.preventDefault){e.preventDefault();}return false;});},setupGlideToLinks:function(contId,dur){var self=this,el=Ut.$(contId),links=el.getElementsByTagName('a'),list,cls,gsId;for(var i=0,len=links.length;i<len;i++){list=Ut.get_DelimitedClassList(links[i].className);for(var j=0,count=list.length;j<count;j++){cls=list[j];gsId=cls.slice(5);if(gsId){Ev.add(links[i],'click',function(self,gsId,dur){return function(e){self.scrollToId(gsId,dur);if(e&&e.preventDefault){e.preventDefault();}return false;};}(self,gsId,dur));}}}}};Ut.augment(SDiv.prototype,Glide_Scroll_Controls);})();

if ( DYN_WEB.Scroll_Div.isSupported() ) {

     DYN_WEB.Event.add( window, 'load', function() {
    // arguments: id of scroll area div, id of content div
    var wndo = new DYN_WEB.Scroll_Div('wn', 'lyr1');

    // args: id, axis ('v' or 'h')
    // distance per click, duration of glide
    wndo.addGlideControls('scrollLinks', 'h', 600, 300);
});
}

</script>
]]></description>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.