geoXML3 : How to change the fillcolor of polygones

2,693 views
Skip to first unread message

Fred67

unread,
Feb 27, 2011, 2:55:56 PM2/27/11
to Google Maps JavaScript API v3
Hello,
I'm new with geoXML3 and globaly JavaScript.

I have 3 kml files defined and check under Google Earth. In theses 3
files are severl area per files in the country.
I used KmlLayers to show the area on the map, but sometimes some
regions are missing.
Searching on the web, I found geoXML3.js to show the area on the map
with a better speed and result.
But, I found several versions of geoXML3.
With the first, all my area have the same fillcolor (and not this
define in the kml file).
With the secons, all area have a different fillcolor.

Is somebody able to explain me :
1 - why geoXML3 change the fillcolor?
2 - How can I define dynamically the fillcolor for 1 kml file ?

I use the following code :

<script type="text/javascript" src="geoxml3.js"></script>

<script type="text/javascript">
function initialize() {

var infowindow = new google.maps.InfoWindow({size: new
google.maps.Size(150,50) });
var latlng = new google.maps.LatLng(32.5890, -96.308871);
var myOptions = {
zoom: 10,
center: latlng,
mapTypeControl: true,
mapTypeControlOptions: {style:
google.maps.MapTypeControlStyle.DROPDOWN_MENU},
navigationControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
var geoXml = new geoXML3.parser({map: map, singleInfoWindow: true });
geoXml.parse('f_kml/ouest_r.kml');
}
</script>




Thanks in advance.

Fred

geoco...@gmail.com

unread,
Feb 27, 2011, 3:48:29 PM2/27/11
to Google Maps JavaScript API v3
On Feb 27, 11:55 am, Fred67 <frederic.debe...@wincor-nixdorf.com>
wrote:
> Hello,
> I'm new with geoXML3 and globaly JavaScript.
>
> I have 3 kml files defined and check under Google Earth. In theses 3
> files are severl area per files in the country.
> I used KmlLayers to show the area on the map, but sometimes some
> regions are missing.
> Searching on the web, I found geoXML3.js to show the area on the map
> with a better speed and result.
> But, I found several versions of geoXML3.
> With the first, all my area have the same fillcolor (and not this
> define in the kml file).
> With the secons, all area have a different fillcolor.

The best place (the current development branch) is:
http://code.google.com/p/geoxml3/source/browse/branches/polys/geoxml3.js

>
> Is somebody able to explain me :
> 1 - why geoXML3 change the fillcolor?

Can't tell from the information provided.

> 2 - How can I define dynamically the fillcolor for 1 kml

Can't tell from the information provided.

> I use the following code :
>

Please post a link to a map that exhibits the problem, not code.

-- Larry

>

Plesase
> Thanks in advance.
>
> Fred

Fred67

unread,
Feb 27, 2011, 4:54:05 PM2/27/11
to Google Maps JavaScript API v3
here is a link to see the result:

http://wnmapcrm.free.fr/tests/index.php


The parsed kml file is a union of several kml files done via Google
Earth. I select for all a color red and transparancy of 50%.
In the results page, I can see the differents regions , but each have
a different fill color. I would like to be able either to specify a
fill color, either to use the fill color defined in the kml file.

Regards,
Fred

geoco...@gmail.com

unread,
Feb 28, 2011, 12:52:16 AM2/28/11
to Google Maps JavaScript API v3

Fred67

unread,
Feb 28, 2011, 4:09:02 AM2/28/11
to Google Maps JavaScript API v3
Hi Larry,

I feel very stupid today....

In your first link, the map appear with region in red as I want. But
in the second link, the region are in blue as default value from
geoxml3.js (if I understood).
I check the both link to ciompare and find the difference, but without
any success.

If the differences are not in the html page or in js files, maybe it's
coming from the kml files???

>
> geoxml3 does not support StyleMap:http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.htm...
>
> This is what you should see with the latest version of geoxml3 (with
> your unmodified kml):http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.htm...
>
> -- Larry

I'm really disappointed..

Regards,
Fred

geoco...@gmail.com

unread,
Feb 28, 2011, 8:28:26 AM2/28/11
to Google Maps JavaScript API v3
On Feb 28, 1:09 am, Fred67 <frederic.debe...@wincor-nixdorf.com>
wrote:
> Hi Larry,
>
> I feel very stupid today....
>
> In your first link, the map appear with region in red as I want. But
> in the second link, the region are in blue as default value from
> geoxml3.js (if I understood).
> I check the both link to ciompare and find the difference, but without
> any success.
>
> If the differences are not in the html page or in js files, maybe it's
> coming from the kml files???

Yes. The first assigns all the polygons the StyleUrl:
<styleUrl>#gitesdegaule.fr1</styleUrl>

The second is unmodified.

>
>
>
> > geoxml3 does not support StyleMap:http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.htm...
>
> > This is what you should see with the latest version of geoxml3 (with
> > your unmodified kml):http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.htm...
>
> >   -- Larry
>
> I'm really disappointed..

You could do any of the following (and probably others I haven't
thought of):
1. not use the StyleMap functionality of kml
2. implement the StyleMap element yourself and use your own local
version of geoxml3.
3. implement the StyleMap element yourself and submit that for
inclusion in geoxml3.
4. create an "Enhancement" request for geoxml3.

-- Larry


>
> Regards,
> Fred

Fred67

unread,
Feb 28, 2011, 8:42:27 AM2/28/11
to Google Maps JavaScript API v3
Hello Larry,

Yes, it's what I'm checking.
For the moment I put the focus on polygon, and I saw in the code, you
defined a normal Style.
I'm looking what I can do exactly. The solution could be the
following :
Define 3 style with a fdifferent fill color for polygon.
And when I will parse the file, then I will also send the style I
want.

Thanks for your help.

fred

geoco...@gmail.com

unread,
Feb 28, 2011, 7:33:52 PM2/28/11
to Google Maps JavaScript API v3
On Feb 28, 5:28 am, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:
5. Implement "support" for StyleMap, but not all the functionality.
Change geoxml3 to understand the StyleMap tag and default to the
"normal" style, leave implementation of other functionality for later.
(that is probably not too hard, and it would have prevented you from
seeing a problem. I may look at that when time permits)

  -- Larry

>
>
>
>
> > Regards,
> > Fred- Hide quoted text -
>
> - Show quoted text -

Fred67

unread,
Mar 1, 2011, 6:17:45 AM3/1/11
to Google Maps JavaScript API v3
Hi Larry,

Thanks for your support, it's works perfectly. What was missing , was
how to define my onwn style and how to apply to my polygon.

Finaly, I created my 3 styles (Red , Green, Blue).
I will define by php the list of department (region of the country) I
want to display and the color I want for each in 2 different table
(filename[], color[])
I will parse all files and then after in the useTheData() function,
check which color I have to apply.

Just one point more, How to change the infowindow for the polygon, is
it the same than for a marker, can I define it?
I try in the useTheData() :
geoXmlDoc[j].placemarks[i].polygon.setOptions(geoXmlDoc[j].placemarks[i].polygon.infoWindow.setContent("bonjour"));

but it's not working, I will search more..

Regards,
Fred

geoco...@gmail.com

unread,
Mar 1, 2011, 8:54:12 AM3/1/11
to Google Maps JavaScript API v3
I'm not sure what you are trying to do. If the default createPolygon
function doesn't create the infoWindow you want (from the <name> and
<description> elements in the placemark), you can define a custom
createPolygon function that does. It will be called with the
placemark object and the doc object.
That functionality is not particularly well tested.

-- Larry

geoco...@gmail.com

unread,
Mar 1, 2011, 9:26:08 AM3/1/11
to Google Maps JavaScript API v3
On Mar 1, 3:17 am, Fred67 <frederic.debe...@wincor-nixdorf.com> wrote:
Actually, I would think something like that might work (emphasis on
_might_) if you have individual infowindows for each polygon, most of
my testing was done with a single global infowindow.

Do you have a link to a map where you tried to do that? The link you
posted at the beginning of the thread doesn't look like it has been
updated.

-- Larry

geoco...@gmail.com

unread,
Mar 1, 2011, 9:29:08 AM3/1/11
to Google Maps JavaScript API v3
On Mar 1, 6:26 am, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:
> On Mar 1, 3:17 am, Fred67 <frederic.debe...@wincor-nixdorf.com> wrote:
>
> > Hi Larry,
>
> > Thanks for your support, it's works perfectly. What was missing , was
> > how to define my onwn style and how to apply to my polygon.
>
> > Finaly, I created my 3 styles (Red , Green, Blue).
> > I will define by php the list of department (region of the country) I
> > want to display and the color I want for each in 2 different table
> > (filename[], color[])
> > I will parse all files and then after in the useTheData() function,
> > check which color I have to apply.
>
> > Just one point more, How to change the infowindow for the polygon, is
> > it the same than for a marker, can I define it?
> > I try in the useTheData() :
> > geoXmlDoc[j].placemarks[i].polygon.setOptions(geoXmlDoc[j].placemarks[i].po lygon.infoWindow.setContent("bonjour"));
>
> Actually, I would think something like that:

geoXmlDoc[j].placemarks[i].po lygon.infoWindow.setContent("bonjour")

> might work (emphasis on _might_) if you have individual
> infowindows for each polygon, most of my testing was done with a
> single global infowindow

(because I like the default v2 infowindow behavior better than lots of
infowindows open at the same time).

-- Larry

geoco...@gmail.com

unread,
Mar 5, 2011, 1:20:42 PM3/5/11
to Google Maps JavaScript API v3
On Feb 27, 11:55 am, Fred67 <frederic.debe...@wincor-nixdorf.com>
wrote:
> Hello,
> I'm new with geoXML3 and globaly JavaScript.
>
> I have 3 kml files defined and check under Google Earth. In theses 3
> files are severl area per files in the country.
> I used KmlLayers to show the area on the map, but sometimes some
> regions are missing.

While I was investigating implementing StyleMap in geoxml3, I
discovered an issue with your kml, which may explain why "some regions
are missing".

Some of the coordinates are being output in exponential notation
(-3.600000000000001e-007), that apparently doesn't (currently) work
with KmlLayer and doesn't validate with Feed Validator (http://
www.feedvalidator.org/), but it does work with geoxml3.

-- Larry

geoco...@gmail.com

unread,
Mar 5, 2011, 4:15:34 PM3/5/11
to Google Maps JavaScript API v3
On Mar 5, 10:20 am, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:
> On Feb 27, 11:55 am, Fred67 <frederic.debe...@wincor-nixdorf.com>
> wrote:
>
> > Hello,
> > I'm new with geoXML3 and globaly JavaScript.
>
> > I have 3 kml files defined and check under Google Earth. In
> > theses 3 files are severl area per files in the country.
> > I used KmlLayers to show the area on the map, but sometimes some
> > regions are missing.
>
> While I was investigating implementing StyleMap in geoxml3, I
> discovered an issue with your kml, which may explain why "some
> regions are missing".
>
> Some of the coordinates are being output in exponential notation
> (-3.600000000000001e-007), that apparently doesn't (currently) work
> with KmlLayer and doesn't validate with Feed Validator
> (http://www.feedvalidator.org/), but it does work with geoxml3.

If I fix them, it even works on Google Maps:
http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=http:%2F%2Fwww.geocodezip.com%2Fgeoxml3_test%2Fwnmapcrm_free_fr_tests_ouest_r0_kml.xml&aq=&sll=0,0&sspn=126.783043,223.242188&ie=UTF8&t=h&z=6

The original doesn't:
http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=http:%2F%2Fwww.geocodezip.com%2Fgeoxml3_test%2Fwnmapcrm_free_fr_tests_ouest_r_kml.xml&aq=&sll=45.756693,-0.671247&sspn=7.206147,13.952637&ie=UTF8&t=h&z=0

geoco...@gmail.com

unread,
Mar 7, 2011, 2:06:27 AM3/7/11
to Google Maps JavaScript API v3
On Feb 27, 9:52 pm, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:
> On Feb 27, 1:54 pm, Fred67 <frederic.debe...@wincor-nixdorf.com>
> wrote:
>
> > here is a link to see the result:
>
> >http://wnmapcrm.free.fr/tests/index.php
>
> > The parsed kml file is a union of several kml files done via
> > Google Earth. I select for all a color red and transparancy of
> > 50%. In the results page, I can see the differents regions , but
> > each have a different fill color. I would like to be able either
> > to specify a fill color, either to use the fill color defined in
> > the kml file.
>
> geoxml3does not supportStyleMap:
http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.htm...

geoxml3 now supports StyleMap "normal" style. You can implement
highlight functionality as well, but it takes additional code.
(now red, not particularly exciting in this case, but it would have
prevented you from having to change it)

  -- Larry

>
>
>
>
>
>
>
>
> > Regards,
> > Fred

Fred67

unread,
Mar 7, 2011, 4:57:07 AM3/7/11
to Google Maps JavaScript API v3


Hello Larry,

I updated my link : http://wnmapcrm.free.fr/tests/index.php

Now you can see the results using geoxml3.

Thanks for your help and your supports.

Fred

Fred67

unread,
Mar 7, 2011, 5:00:14 AM3/7/11
to Google Maps JavaScript API v3
The region color is a global calculation.

When you put the mouse over a department, then you can see the result
for this one (the color change too).
Reply all
Reply to author
Forward
0 new messages