---
metadata:
  - name: generator
    content: Diplodoc Platform v5.39.1
alternate:
  - https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/geoXml.load.md
  - https://yandex.com/dev/jsapi-v2-1/doc/ru/v2-1/ref/reference/geoXml.load.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/jsapi-v2-1/doc/en/llms.txt

# geoXml.load

Static function.

Loads an XML file with geographic data and converts it into a [GeoObjectCollection](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoObjectCollection.md). The generated collection can be passed to the specified function for subsequent processing. Supported XML data formats: YMapsML, KML, GPX. For the topmost collection of geo objects from a GPX file, the following presets are available: 
- 'gpx#interactive' - Provides outputting information about a point on a route when clicked. Additionally, 	when this preset is used, the following geo object properties become available in the balloon layout: time, velocity, trackName, 	trackDescription, pointName, pointDescription, lon, lat, sym. Used by default.
- 'gpx#plain' - Items in GPX collections behave like normal geo objects.

**Returns** Promise object. If the XML file at the specified URL is downloaded successfully, the promise will be resolved and will get an object with the following fields (as parameters): 
- geoObjects - Collection of geo objects [GeoObjectCollection](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/GeoObjectCollection.md).
- mapState - Description of the map state [IMapState](https://yandex.com/dev/jsapi-v2-1/doc/en/v2-1/ref/reference/IMapState.md) (only for YMapsML).

```javascript
{ vow.Promise } geoXml.load(url)
```

**Parameters:**

#|
|| **Parameter** | **Default value** | **Description**  ||
|| [`url`](#param-url)[*](*star) | — | Type: String

The URL of a file with geographical data. ||
|#

\* Mandatory parameter/option.

**Example:**

```javascript
// Creating and initializing map...

// Loading and displaying a ymapsml file from the My Maps service
ymaps.geoXml.load('http://maps.yandex.ru/export/usermaps/HNQ5uTUgbjy6L0dW2uReUjSoXb1Ad7jw/')
     .then(function (res) {
         // Adding elements of the ymapsml file to the map
         map.geoObjects.add(res.geoObjects);
         // Setting the map boundaries and type.
         // res.mapState.getBounds() boundaries are applied to the map asynchronously,
         // because we need to get information about available zoom levels for these bounds
         // res.mapState.getType() is applied to the map synchronously.
         if (res.mapState) {
             res.mapState.applyToMap(map).then(function () {
                 alert('Boundaries applied to the map ' + res.mapState.getBounds().toString());
             });
         }
         // If information about boundaries isn't provided in repr:View in the YMapsML file,
         // we can apply gml:boundedBy for the top ymaps:GeoObjectCollection element
         else if (res.geoObjects.properties.get('boundedBy')) {
             map.setBounds(res.geoObjects.properties.get('boundedBy'), {
                 checkZoomRange: true
             });
         }
    });

// Loading and displaying a KML file
ymaps.geoXml.load('https://sandbox.api.maps.yandex.net/examples/ru/2.1/geoxml_display/geoObjects.kml')
     .then(function (res) {
         map.geoObjects.add(res.geoObjects);
    });

// Loading and displaying a GPX file
ymaps.geoXml.load('https://sandbox.api.maps.yandex.net/examples/ru/2.1/geoxml_display/geoObjects.gpx')
     .then(function (res) {
         res.geoObjects.options.set({
             balloonContentBodyLayout: ymaps.templateLayoutFactory.createClass(
             // The balloon will only show the geo object's name property and the speed
             '<b>{{ properties.name }}</b> {{ properties.velocity }}'
             )
        });

         map.geoObjects.add(res.geoObjects);
         // Metadata about boundaries from a GPX file is stored in properties of the res.geoObjects collection.
         // Applying these boundaries to the map.
         if (res.geoObjects.properties.get('boundedBy')) {
             map.setBounds(res.geoObjects.properties.get('boundedBy'), {
                 checkZoomRange: true
             });
         }
     });
```

[*star]: Mandatory parameter/option.