janmeet / geoxml3

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

Marker custom icons fail #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a KML file with markers' icons from 
http://code.google.com/p/google-maps-icons/ (or other not 32x32px)
2. Load it into a map

What is the expected output? What do you see instead?
The markers' icons are cut to 32x32px. The marker icon should be displayed 
fullsize.

What version of the product are you using? On what operating system?
branch "network_link" && trunk version / Windows XP

Please provide any additional information below.
I think the solution would be to change the code in `if 
(!!doc.styles[styleID].href)` of the processStyles function, from:
{{{
        // Init the style object with a standard KML icon
        doc.styles[styleID].icon =  new google.maps.MarkerImage(
          doc.styles[styleID].href,
          new google.maps.Size(32, 32),
          new google.maps.Point(0, 0),
          new google.maps.Point(16, 12)
        );
}}}
To:
{{{
    var icon = new Image();
    icon.src = doc.styles[styleID].href;
        // Init the style object with a standard KML icon
        doc.styles[styleID].icon =  new google.maps.MarkerImage(
          doc.styles[styleID].href,
          new google.maps.Size(icon.width, icon.height),
          new google.maps.Point(0, 0),
          new google.maps.Point(16, 12)
        );
}}}

This way, the marker is created with the correct size.
What do you think?

Regards.

Original issue reported on code.google.com by alvaro.d...@gmail.com on 28 Oct 2010 at 10:15

Attachments:

GoogleCodeExporter commented 9 years ago
Can you provide a link to a map that shows the problem or a link to a kml file 
that will expose it?

I have an example here:
http://www.geocodezip.com/geoxml3_test/v3_geoxml3_nonstandard_icon_test.html
But it shows stretching, not cutting.

I'm not sure this will be fixed.  Do Google Maps or kmlLayers support custom 
marker sizes?

Is there a mechanism in kml to specify the size of the icon?

The proposed change breaks scaling and I'm not sure it will work if the icon 
image is not already in the browser's cache.

Original comment by geocodezip on 29 Oct 2010 at 1:36

GoogleCodeExporter commented 9 years ago
With that map and KML, just try to load the geoxml3.js, not from the polys 
branch but from the trunk.
It shows stretching because the geoxml3.js from the polys branch scale the 
marker, but if you use the trunk version, it cut the icons.

However, if you use the code I proposed, the not standard 32x32px icon shows 
correctly; I attach the sample KML file you use in the example with the icons 
changed so you can see it better and the html with the trunk version selected.

Original comment by alvaro.d...@gmail.com on 29 Oct 2010 at 6:58

Attachments:

GoogleCodeExporter commented 9 years ago
As far as I can tell, it works just fine in the polys branch.

http://www.geocodezip.com/geoxml3_test/v3_geoxml3_custom_icon_polys_version.html

Both icons are cut off in the trunk:
http://www.geocodezip.com/geoxml3_test/v3_geoxml3_custom_icon_trunk_version.html
but that version won't even load in IE6.

When I am satisfied with the polys version I will probably move it to the 
trunk, until then, I can back port fixes to the trunk if there is a good reason.

Original comment by geocodezip on 29 Oct 2010 at 8:22

GoogleCodeExporter commented 9 years ago

Original comment by geocodezip on 29 Oct 2010 at 8:23

GoogleCodeExporter commented 9 years ago
It does look like the anchor is being set incorrectly to the middle of the icon 
though.  I added lines that should cross at the location where the icon is 
anchored.  That I will look into addressing in the development version.

Original comment by geocodezip on 29 Oct 2010 at 9:31

GoogleCodeExporter commented 9 years ago
Why to scale the icon if you can leave it with its original size?

Original comment by alvaro.d...@gmail.com on 31 Oct 2010 at 10:41

GoogleCodeExporter commented 9 years ago
KML supports scaling icons:
http://code.google.com/apis/kml/documentation/kmlreference.html#scale

geoxml3 in the polys branch currently supports that, breaking that would be a 
regression.

Original comment by geocodezip on 31 Oct 2010 at 11:44

GoogleCodeExporter commented 9 years ago
I added an issue that I think is related: 
http://code.google.com/p/geoxml3/issues/detail?id=44

Original comment by verm...@nurc.nato.int on 13 Dec 2011 at 11:21

GoogleCodeExporter commented 9 years ago
http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmztest_linkto.html?filename=c
ustomIconKml.xml

Fixed in kmz branch

Original comment by geocodezip on 23 Feb 2012 at 4:12