[ Whereis® API Home ] [ JSON API Home ] [ Object Index ]

The WhereIs JavaScript API allows you to add formatted geometry data to a map directly from a local URI. Supported formats include:

  • KML
  • GeoJSON
  • GPX

To use this feature you will need to include the import library in the libraries parameter of your API request, e.g:

<path>/v2/web/js/ems/?token=5809081097379409920&libraries=map,import

Format

     OpenLayers.Request.GET({
        url: <path_to_kml>,
        success: function(request) {
            // kml format reader. for gpx or geojson use the appropriate reader
            var format = new EMS.Format.KML();
            var features = format.read(request.responseText);
            vectorLayer.addFeatures(features);
        }
    });

Alternatively you can create a layer that asynchronously reads the URI on initialization:

    var vectorLayer = new EMS.Layer.Vector("Vector Overlay", {
        strategies: [new OpenLayers.Strategy.Fixed()],
        protocol: new OpenLayers.Protocol.HTTP({
            url: <path_to_kml>,
            format:new EMS.Format.KML()
        })
    });
   
    // Initialise the map
    var map = new EMS.Map("Map", {
        layers:[new EMS.Layer.Street(), new EMS.Layer.Photo(), new EMS.Layer.Hybrid(), vectorLayer]
    });
NOTES
Icon

You can also use EMS.Format formatters to write existing map features to KML, GeoJSON and GPX, by using the Format.write() function.

Icon

For more information, check out the live examples here:

Add KML

Load KML

Add GeoJSON

Add GPX