Hi Segey,

I know this is quite old, but can you give me a few more example of how the 
hex encoding works?
for example: if 1010 = AL0A, then what would 1020 be?

On Tuesday, July 9, 2013 1:36:04 PM UTC-7, Sergey wrote:
>
> Okay, this is going to be extremely tricky. The GeoChart expects 
> everything to be under a base URL, the maps source. By default, the maps 
> source is set to "https://www.gstatic.com/charts/geochart/10/";. You can 
> set a new maps source by calling google.visualization.
> GeoChart.setMapsSource(newSourceUrl), where newSourceUrl is your new URL 
> (for example, newSourceUrl = *'http://chrisdblumberg.com/maps/ 
> <http://chrisdblumberg.com/maps/>'*). From this point on, you could 
> figure out what resources the GeoChart is requesting yourself, and place 
> them there one by one; but I'm going to help you a bit more.
>
> Your file isn't formatted correctly. It's not even valid javascript. 
> You're missing braces around all your features and you're not closing a lot 
> of the braces and brackets that you do have. Your lat/longs aren't supposed 
> to be formatted as a single string, but as two separate strings, as they 
> are in the example file. However, because I'm an unreasonably nice person, 
> I've decided to help you with all of those problems. So here is the fixed 
> map 
> file<https://googledrive.com/host/0B5-GB-Crk0g3Ry1WQWpFRENSMVE/js/data/maps/mapfiles/US-AL_PROVINCES.js>,
>  
> and here is a jsfiddle using it <http://jsfiddle.net/j2WB2/>. But I'm 
> sure you'll notice a few funny things happening. The first thing is that 
> all the counties look off on the Y axis. This is because all the 
> coordinates are supposed to be in *projected Mercator space*, like I 
> mentioned in my last response. You can find the formula for converting your 
> coordinates on the Mercator Projection Wikipedia 
> page<http://en.wikipedia.org/wiki/Mercator_projection>. 
> For mercator, you only need to project the latitude, and not the longitude, 
> so it's pretty easy. For simplicity sake, you can just use the formula 
> below:
> projectedLatitude = (180 / PI) * log(tan(latitude / 180 * PI / 2 + PI / 
> 4));
>
> The other thing that you may notice is that the regions in my example 
> aren't being highlighted. This is a harder problem to solve. It's happening 
> because the GeoChart tries to geocode the IDs without ever checking if the 
> given IDs match the map IDs. This is a bug. Kind of. Until I figure out a 
> permanent fix, you're going to have to hack around it. The trick here is to 
> fit the format of a province code so that the GeoChart doesn't fall back on 
> geocoding. The GeoChart will fall back on geocoding (in the case of a 
> province) if the ID doesn't match the format of "two letters, followed by a 
> dash, followed by two alphanumeric characters". One way to get around this 
> problem is to encode your provinces as hex, and use AL as the 'country 
> code' (I put it in quotes because it's not really the country code, and 
> using US-AL-XX doesn't work). So, since everything is in the format of 
> US-AL-1DDD (where D's are digits), and all the codes -1000 are under 255, 
> we can encode them as hex. So US-AL-1001 becomes AL-01, US-AL-1005 becomes 
> AL-05, US-AL-1010 becomes AL-0A, and so on. Here is a demo where that 
> works <http://jsfiddle.net/f3sXW/>. Note that I'm using a different path 
> there and loading a different map, where all the counties are renamed.
>
> The other polygons in that file are the other states. Good call on leaving 
> them alone, since now you can make sure that your counties match up to 
> them, and you can have some context for what you're looking at.
>
> - Sergey
>
>
> On Tue, Jul 9, 2013 at 2:48 PM, Bluestreak2k5 
> <bluest...@yahoo.com<javascript:>
> > wrote:
>
>> Thanks so much Sergey!
>>
>> I have converted the KML to a JS file like you linked me to, it is here:
>> http://chrisdblumberg.com/us_counties/alabama_counties.js
>>
>> I replaced the polygon id="US-AL" with all the polygons of the individual 
>> counties.
>>
>> Each county is represented by an ID using the FIPS code, such as 
>> US-AL-1001 would represent Autauga county in Alabama. This should allow 
>> for easy future expansion as this is a Unique identifier to each county.
>>
>> How would I go about testing this map now, and would this be the correct 
>> way of doing it? I wasn't sure about the other polygons that were in that 
>> file so I left them all alone and are located at the bottom.
>>
>> Chris
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Google Visualization API" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to google-visualization-api+unsubscr...@googlegroups.com<javascript:>
>> .
>> To post to this group, send email to 
>> google-visua...@googlegroups.com<javascript:>
>> .
>> Visit this group at 
>> http://groups.google.com/group/google-visualization-api.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-visualization-api+unsubscr...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to