Google Maps
Last updated
Was this helpful?
Last updated
Was this helpful?
CARTO provides a powerful way to visualize data from your datawarehouse with . By utilizing the of deck.gl you can bring data from a table, a tileset or even a SQL directly all from JS.
After completing this guide, you will have your first Google Maps API map with data from your datawarehouse!
At this point you will have a simple map:
Then you need to provide the credentials for connecting to the CARTO 3 platform, as explained here. Here we are using a token with access to some public datasets in BigQuery. You will need to create a token with access to the datasets you want to visualize.
connection
is the name of the connection to BigQuery in the CARTO 3 Workspace.
type
defines the type of dataset. In this case, we are going to visualize a table so we use one of the constants defined in the MAP_TYPES
enumeration.
data
contains the dataset that we want to visualize. It can be the name of a table, the name of a tileset, or a SQL query. In this case we are going to provide a table name. The CartoLayer
will make the appropriate requests to the Maps API to retrieve the GeoJSON features from the BigQuery table.
We are going to start with the Hello World example from the Google Maps Javascript API , but centering the initial view on the United States and zoom level 4. To simplify the example, we are going to embed the JavaScript code and the CSS declarations in the HTML file.
We are going to use the new for the Maps Javascript API. These features add support for vector maps, 3D graphic content, continuous zoom and tilt/heading parameters. Please follow the instructions to in the Google Cloud Console.
View this step
The first step you need to perform is to add the dependencies, including the CARTO :
From v8.6, the deck.gl class automatically detects at runtime which rendering type is used. The Vector rendering mode is in general more performant, and the GoogleMapsOverlay class offers several features not available when using Raster rendering such as:
Now you can add a map layer from the public account. In order to add the layer, we will use the class from deck.gl. We need to specify the layers as an array. In this case, we only have one from the deck.gl CARTO submodule. We pass the following parameters to the constructor:
Style parameters. In order to display the information, the uses the to style the features, so all the properties of this class are supported. The style parameters depend on the dataset type of geometry. In this case, we are adding a point layer, so we specify the point color using the getFillColor
property, the circle outline color with the getLineColor
property, and the point and outline sizes through the pointRadiusMinPixels
and lineWidthMinPixels
properties.
Finally you need to use the function on the object to add the layer to the map.
You can explore the final step