The google API supports creating a heat map based on a set of geographic coordinates. How to do when we need to generate this map based on zip codes?
In the code below, the array d contains the list of coordinates to add to the heatmap, which we can manually add by inserting an object of the type new google.maps.LatLng (-27.522551, -48.445368), passing the parameters Latitude and Longitude.
As with my problem, we only have one list of zip codes, so we first need to convert this list of zip codes to a coordinate list.
We do this through code:
var geocoder = new google.maps.Geocoder (); geocoder.geocode ({'address': "88111-280"}, function (results, status) {cb (results [0] .geometry.location.lng (), results [0] .geometry.location.lat () );});
After creating the object Geocoder, we pass a string with the zip code, and the function of callback,
Once we get the coordinates, we get them by the functions results [0] .geometry.location.lng () and results [0] .geometry.location.lng (), passing to the cb () function to follow with the code.
Given the limit of 10 API calls per second, we have the following example code:
Artem Bali
Leave a Reply