Hello Sergey,
This was a very impressive project and I have a similar requirement but 
with 3 digit Zip codes instead of counties. I found this site that has zip 
code polygon data but before I start digging into it, I wanted to check if 
it can be done with the GeoMap or GeoChart. Could you please provide some 
help if possible? Here is the example URL:
http://www.usnaviguide.com/zip.htm

Thanks,
-H


On Thursday, March 20, 2014 3:20:21 PM UTC-4, Sergey wrote:
>
> If I remember correctly (and it has been a while), it would be AL14. The 
> way that this works is that we drop the initial "10" because it's redundant 
> between all the counties, and just convert the second part to hex. So in 
> your example, we would just want the hex value of 20. However, all of this 
> is kind of moot at this point, since the GeoChart has been changed to not 
> ignore invalid-looking region codes. So using AL-1010 should work now. 
> However, if you're using Blue's maps, that's irrelevant to you because he 
> has coded them to use the hex encoding already and you can't change that. I 
> simply bring it up if you are making your own maps.
>
> - Sergey
>
>
> On Thu, Mar 20, 2014 at 3:14 PM, Peter Chon <[email protected]<javascript:>
> > wrote:
>
>> 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.G
>>> eoChart.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 <[email protected]>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 [email protected].
>>>> To post to this group, send email to [email protected].
>>>>
>>>> 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 [email protected]<javascript:>
>> .
>> To post to this group, send email to 
>> [email protected]<javascript:>
>> .
>> Visit this group at 
>> http://groups.google.com/group/google-visualization-api.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
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