emnadridi / gmaps4jsf

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

jsVariable for iconComponent #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When creating multiple markers through use of a backing bean, unique
jsVariable names are able to be assigned to the markers but not the icons.
This leads to all of the markers having the same image.

This may also be problematic for htmlInformationWindowComponent, but I have
not tested this yet.

Original issue reported on code.google.com by william....@gmail.com on 30 Sep 2008 at 4:47

GoogleCodeExporter commented 9 years ago
Why do u need unique JS variables for the icons.
You just add an icon component to the parent marker easily.

Original comment by Hazem.sa...@gmail.com on 30 Sep 2008 at 1:22

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Icon icon1 = new Icon();
icon1.imageURL("xyz.png");

Icon icon2 = new Icon();
icon2.imageURL("xyz2.png");

marker1.add(icon1);
marker2.add(icon2);

Original comment by Hazem.sa...@gmail.com on 30 Sep 2008 at 1:26

GoogleCodeExporter commented 9 years ago
I am adding the icons to the markers in a loop, and for some reason the markers 
all
appear the same rather than taking on their own images. I suspect it is because 
they
are named the same.:

        for (int i=0;i<images.length;i++){
            Marker mark = new Marker();
            mark.setJsVariable("mark"+Integer.toString(i+1));
            mark.setLatitude(images[i].getLat());
            mark.setLongitude(images[i].getLon());
            Icon icon = new Icon();
            icon.setImageURL("/GHS/images/"+images[i].getUrl());
            mark.getChildren().add(icon);
            map.getChildren().add(mark);
        }

Original comment by william....@gmail.com on 30 Sep 2008 at 1:49

GoogleCodeExporter commented 9 years ago
I have modified the code and found that even if the icons have unique variable 
names,
they images still appear the same. It seems that the markers may be calling the 
same
"createIconFunctionnull()" instead.

By using: icon.setId("icon"+Integer.toString(i+1)); , the problem is resolved by
creating different function names.

Original comment by william....@gmail.com on 30 Sep 2008 at 6:11

GoogleCodeExporter commented 9 years ago
Yes. You have to set ids for Icons.
It is not a defect.

Original comment by Hazem.sa...@gmail.com on 30 Sep 2008 at 10:36