πŸ”§ KML files

How to update from Smart Map to Google Maps

Follow the instructions below to learn how to update to the new Google Maps plugin...

{# OLD #}
{% set kmlFile = entry.kmlFile.one() %}
{% set options = {
    'height': 400,
    'center': {'lat':34.0522342, 'lng':-118.2436849}
} %}

{% if kmlFile %}
    {{ craft.smartMap.kml(kmlFile, options) }}
{% endif %}
{# NEW #}
{% set kmlFile = entry.kmlFile.one() %}
{% set options = {
    'height': 400,
    'center': {'lat':34.0522342, 'lng':-118.2436849}
} %}

{% if kmlFile and kmlFile.url %}
    {{ googleMaps.map([], options).kml(kmlFile.url).tag() }}
{% endif %}

At a glance, the code hasn't changed much. But internally, the KML functionality now operates much differently than it did previously.

Major functional changes:

  • You are now creating a map object first, before applying the KML layer as a separate step.
  • This demonstrates the concept of chaining.
  • Instead of using a complete Asset, you must only pass a valid URL into the kml method.

New Documentation

See the complete new KML Layers documentation.