GeoMap is not a constructor Error

340 views
Skip to first unread message

Bluestreak2k5

unread,
Dec 11, 2011, 12:53:05 PM12/11/11
to Google Visualization API
Hi,

I am getting a "google.visualization.GeoMap is not a constructor" in
Firefox, but yet this project was working weeks ago, with no change to
this javascript.

http://chrisdblumberg.com/unemployment/index.html

I have checked the GeoMap docs, and all the pages work, and even my
old version works, however this one doesn't, but I have no idea why.

Any help would be great,
Thanks.

Roni Biran

unread,
Dec 12, 2011, 3:05:04 AM12/12/11
to google-visua...@googlegroups.com
I saw that you're loading the geochart package and drawing the GeoMap. The GeoMap uses the geomap package. Can it be that simple?





--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.


EZChart

unread,
Dec 12, 2011, 3:20:51 AM12/12/11
to google-visua...@googlegroups.com
This can explain the change, because until the December 7th release the geochart package also included GeoMap. We fixed this, and now in order to use GeoMap one must load the geomap package.

Bluestreak2k5

unread,
Dec 12, 2011, 11:51:03 AM12/12/11
to Google Visualization API
Yes changing the geochart to geomap fixed the problem, was there a
geomap package before? Because the few examples of geomaps I saw had
geochart as the package when I created this.

Anyway thanks for the help.

On Dec 12, 3:20 am, EZChart <ezch...@google.com> wrote:
> This can explain the change, because until the December 7th release the
> geochart package also included GeoMap. We fixed this, and now in order to
> use GeoMap one must load the geomap package.
>
>
>
>
>
>
>
> On Mon, Dec 12, 2011 at 10:05 AM, Roni Biran <roni.bi...@gmail.com> wrote:
> > I saw that you're loading the geochart package and drawing the GeoMap. The
> > GeoMap uses the geomap package. Can it be that simple?
>

Bluestreak2k5

unread,
Dec 12, 2011, 12:09:22 PM12/12/11
to Google Visualization API
Also, since I am using the old version "GeoMap" right now, is it
possible to move to the GeoChart newer version, and what would I need
to do.

The website is working, so you can see what I was doing now.

asgallant

unread,
Dec 12, 2011, 12:43:13 PM12/12/11
to google-visua...@googlegroups.com
At a glance, your code looks to be compatible with the GeoCharts - just change the package from 'geomap' to 'geochart'.  Also of note, the GeoCharts support an option that might be a good end-route for the color-array generating code you have in there:

colorAxis: {
    values: [minValue, 0, maxValue],
    colors: ['#FF0000', '#FFFFFF', '#00FF00']
}

This assigns each value in the 'values' array to a color in the 'colors' array, and the chart applies a gradient between the colors for values in between.

Bluestreak2k5

unread,
Dec 12, 2011, 5:09:43 PM12/12/11
to Google Visualization API
Ok I had changed everything over to GeoChart and even used the
ColorAxis, however, multiple issues came up.
First:GeoChart throws errors on the last Chart where unemployment %
numbers are really long. I'm assuming that I would have to round them
off to 2 or 3 decimal points. It still draws the image, and I can see
all the information when highlighting each state, however, the legend
at the bottom breaks and doesn't show anything.
Second:Color Axis seems to break when my minValue or MaxValue are 0.
So for instance I may end up with [minValue =0, 0, maxValue =10000],
or the reverse, minValue = -10000, 0, maxValue = 0] and giving it the
range of just [minValue, maxValue] doesn't work because even if the
number is positive it can show up the wrong color.
I fixed #2 by writing some new ColorArray functions to deal with it.
However the first problem still happens, although for some year spans
it doesn't throw errors.
For example...the default throws errors, but starting Jan 1987 and
leaving the end the same, doesn't throw errors at all.
A new link for the newer version until its stable:
http://chrisdblumberg.com/unemploymentNew/

Viz Kid

unread,
Dec 13, 2011, 6:39:50 AM12/13/11
to google-visua...@googlegroups.com

Thank you for reporting this.
We will look into these issues. It seems that rounding the values of the range does solve the problem as a workaround.

  Viz Kid

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.

asgallant

unread,
Dec 13, 2011, 9:17:05 AM12/13/11
to google-visua...@googlegroups.com
The colorAxis option is not locked in to what I listed there.  If your minimum is 0, then set up the option like this:

colorAxis: {
    values: [0, maxValue],
    colors: ['#FFFFFF', '#00FF00']
}

all the option does is map colors to values - it can have as many or as few elements in it as you wish.

Bluestreak2k5

unread,
Dec 14, 2011, 4:50:35 PM12/14/11
to Google Visualization API
asgallant, thats basically what I did. I did a 3 way if statement, if
minvalue =0 then I did that, if maxvalue was 0 then reverse, if
neither, do the first thing you said.

Also, I tried rounding the values, have updated it. This doesn't solve
the first issue about the legend not showing up.

One thing I noticed about the problem is it seems the legend is
backwards when it is broken. For example highlight over a green state
and the arrow on the legend moves to the right...but it should be on
the left. Move over a red state and the legend moves to the left, but
it should be on the right.

However, on the 1987 to 2011 one that actually works, it doesn't do
that. Maybe something to do with the range not being big
enough...maybe less then 10. This range hardly ever goes above 10, but
does in 1987 case.

asgallant

unread,
Dec 15, 2011, 10:41:41 AM12/15/11
to google-visua...@googlegroups.com
I created a jsfiddle with your code: http://jsfiddle.net/StLtd/1/.  Warning: major hack job to get it running there, pay attention to the four draw functions at the top of the JS window only.  Note that the charts are drawing off of a static copy of the data I pulled from your site, so the form does nothing.

The major changes I made was to draw them as GeoCharts instead of GeoMaps, use the colorAxis option instead of the colors option, and round off your unemployment % changes.  Everything looks like it is running correctly.


Luis Garcia

unread,
Oct 3, 2016, 9:16:16 AM10/3/16
to Google Visualization API
In the package loader you need to call all the packages at the same line,

Before
    google.charts.load('current', {'packages':['table']});
    google.charts.load('current', {packages: ['corechart', 'line']});

After
    google.charts.load('current', {packages: ['corechart','line','table']});

That's work for me.
Reply all
Reply to author
Forward
0 new messages