itamair / geoxml3

Automatically exported from code.google.com/p/geoxml3
0 stars 0 forks source link

Image references in description html to images found inside the kmz zip are broken #69

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Steps to reproduce:
1. Get/make a KMZ with images inside and a reference to these images in a 
waypoint description like...
<description><![CDATA[<img src='files/testimage.jpg' width='320' 
height='213'>]]></description>
2. Open this file with geoxml3
3. Click on the waypoint

Expected: an image in the waypoint popup
Actual: broken image

I think you could fix this pretty easily by going through descriptions and 
doing a find and replace for base64 encoded images.

Original issue reported on code.google.com by benma...@gmail.com on 16 Aug 2012 at 12:55

GoogleCodeExporter commented 9 years ago
Do you have an example kmz file that produces this issue?

Original comment by geocodezip on 16 Aug 2012 at 1:29

GoogleCodeExporter commented 9 years ago
See attached.

It's a bit of a simplistic example, but I have real-world kmzs with similar 
structure.

Original comment by benma...@gmail.com on 16 Aug 2012 at 1:42

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you for the example kmz file.

Test case:
http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmztest_linkto.html?filename=i
nternalimage_test_kmz.zip

The image (files/neko.png) in the infowindow <description> field does not 
appear.

<Placemark>
    <name>1</name>
    <Snippet maxLines="0"></Snippet>
    <description><![CDATA[<img src='files/neko.png'>]]></description>
    <styleUrl>#Photo</styleUrl>
    <Point>
        <coordinates>45,45,200</coordinates>
    </Point>
</Placemark>

I don't see a "broken image" in firefox, I just don't see anything, I see the 
"broken image" placeholder in IE(8)

Original comment by geocodezip on 16 Aug 2012 at 4:25

GoogleCodeExporter commented 9 years ago

Original comment by geocodezip on 16 Aug 2012 at 4:25

GoogleCodeExporter commented 9 years ago
Doesn't seem to be supported by Google Maps KML/KMZ parser either.

https://maps.google.com/maps?q=http:%2F%2Fwww.geocodezip.com%2Fgeoxml3_test%2Fin
ternalimage_test_kmz.zip

Original comment by geocodezip on 20 Aug 2012 at 1:06

GoogleCodeExporter commented 9 years ago
seems like the "easy" way would be to look for "<img src=" in the description.  
Problem with that is doesn't _have_ to be that way, the img tag could have 
multiple attributes, "src" doesn't need to be the first.  More complicated 
would be to attach it to the DOM, then look to see if there is an <img> tag, 
and check its src attribute.  Do all your "real-world kmzs with similar 
structure" use conform to:
"<img src="?

Original comment by geocodezip on 20 Aug 2012 at 4:01

GoogleCodeExporter commented 9 years ago
Yeah. Most img tags I've seen do as well but you're right, there's no guarantee.

I thought about doing sort of a find and replace for urls contained in the 
replaced image map. It would probably be pretty slow though

Original comment by benma...@gmail.com on 20 Aug 2012 at 4:14

GoogleCodeExporter commented 9 years ago
Local test copy (attached).  If you have a chance see if it works for you.

http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmztest_linkto_local.html?file
name=internalimage_testB_kmz.zip

Original comment by geocodezip on 21 Aug 2012 at 8:10

Attachments:

GoogleCodeExporter commented 9 years ago
Doesn't seem to work in IE8

Original comment by geocodezip on 21 Aug 2012 at 8:27

GoogleCodeExporter commented 9 years ago
Working for me in Chrome and Firefox.

Original comment by benma...@gmail.com on 21 Aug 2012 at 11:27

GoogleCodeExporter commented 9 years ago
Do you have access to any versions of IE?  Does it work for you there?  Any 
thoughts on what the problem might be?  I don't even see the embedded icon in 
IE (the embedded image fails due to IE limitations).

Original comment by geocodezip on 21 Aug 2012 at 1:39

GoogleCodeExporter commented 9 years ago
Might be this:
http://stackoverflow.com/questions/4807622/setting-img-src-to-a-data-url-via-wor
k-does-not-work-in-ie8

Original comment by geocodezip on 21 Aug 2012 at 1:43

GoogleCodeExporter commented 9 years ago
In IE9 I'm getting a small IE logo instead of the image.

Original comment by benma...@gmail.com on 21 Aug 2012 at 2:45

GoogleCodeExporter commented 9 years ago
Well, that's encouraging, that is the way it is coded:

// IE cannot handle GET requests beyond 2071 characters, even if it's an inline 
image
      if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) && parser.kmzMetaData[mdUrl].dataUrl.length > 2071)
        parser.kmzMetaData[mdUrl].dataUrl =
        // this is a simple IE icon; to hint at the problem...

Do you see the icon?

I'll have to see if IE9 still has that restriction and see if any of the 
workarounds for IE might apply.

Original comment by geocodezip on 21 Aug 2012 at 2:54

GoogleCodeExporter commented 9 years ago
Yeah that's the icon I get. I've read that IE9 doesn't have these restrictions 
anymore (or at least they are massively increased). As a quick test I tried 
removing the lines that replace the image with an IE icon and images are 
working fine in IE9.

Original comment by benma...@gmail.com on 21 Aug 2012 at 3:23

GoogleCodeExporter commented 9 years ago
Cool.  Thank you.  Now need to do more extensive browser sniffing for IE...

Original comment by geocodezip on 21 Aug 2012 at 3:47

GoogleCodeExporter commented 9 years ago
I can't seem to get it to work in IE8.  There seems to be an issue w/ this 
function:

var dehostURL = function (s) {
  var h = location.protocol + "://" + location.host;
  h = h.replace(/([\.\\\+\*\?\[\^\]\$\(\)])/g, '\\$1');  // quotemeta
  return s.replace(new RegExp('^' + h, 'i'), '');
}

The second replace (on s) doesn't seem to work in IE8 when used on the img urls 
in the infoWindow. 

Original comment by geocodezip on 27 Aug 2012 at 12:53

GoogleCodeExporter commented 9 years ago
I think it is now working in IE8 (and Firefox and Chrome).

http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmztest_linkto_local.html?file
name=internalimage_testB_kmz.zip

http://www.geocodezip.com/geoxml3_test/IE8-base64_test.html

Please verify it still works in IE9.

Original comment by geocodezip on 28 Aug 2012 at 1:32

Attachments:

GoogleCodeExporter commented 9 years ago
Still working in IE9

Original comment by benma...@gmail.com on 28 Aug 2012 at 3:06

GoogleCodeExporter commented 9 years ago
Fixed revision 88.

Original comment by geocodezip on 29 Aug 2012 at 4:25

GoogleCodeExporter commented 9 years ago
Test case:
http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmztest_linkto.html?filename=i
nternalimage_testB_kmz.zip

Original comment by geocodezip on 29 Aug 2012 at 4:33