From September, Flash will no longer be supported by Chrome. Prepare for the shift towards HTML5 by visiting our Flash to HTML5 help page

Check it out!

Geolocation

Geolocation information allows the creative agencies to get the current location of the user and create custom functions like locating the nearest store, displaying different text or images etc.

  • Specifications

    Please follow General specifications.

  • Location

    The geolocation information includes approximate latitude and longitude and can be accesed like this:

    var location = Adform.getLocation() // Returns {lat: Number, lng: Number} object
    

    Note: The geolocation will only be provided in the final created tag - the method will return a null value in HTML5 Studio and in the preview in the "Banners" section. 

     

  • Markers

    Markers can be loaded directly through an object or through JSON file:

    		var markers;
    		var req = new XMLHttpRequest();
    
            req.onreadystatechange = function() {
                if (req.readyState == 4 && req.status == 200) {
                    markers = JSON.parse(req.responseText);
                }
            };
            req.open('GET', 'locations.json', true);
            req.send();
    

    JSON file (or a simple object) should contain latitude, longitude and title for each marker:

    {
        "title": "Adform Vilnius",
        "latitude": 54.694997,
        "longitude": 25.298734
    },
    {
        "title": "Adform Copenhagen",
        "latitude": 55.672294,
        "longitude": 12.588974
    }

Don't forget to have a fallback logic in the banner for the cases when the method returns null value - the geolocation may not always be available.