A Dynamic Maps map load is incurred for every instantiation of JavaScript API Map class:
new google.maps.Map()
This is the only activity that incurs a dynamic map load charge. Downloading the JavaScript API library in a <script> does not incur a charge, nor does any user interaction with the map. Panning, zooming, adding markers, etc. are all free.
Optimizing for costs
Since each instantiation of google.maps.Map object counts as one Dynamic Maps load and incurs a charge, it is best practice to reuse the map instance. This is easiest in a single page application (SPA). Once a map is created it cannot be attached to a new DOM node; rather, the state of the map + div should be maintained and used in tandem.
if (map) { //Map already exists, append it
element.append(map.getDiv());
resolve();
} else { //No map yet, create one
element.append('<div id="map_canvas"></div>');
}
Comments
0 comments
Please sign in to leave a comment.