Contributing

How to contribute to Woosmap Recommendation
  1. Contribute to Recommending API Profiles
    1. Synchronous and Asynchronous
  2. Contributing Use Cases
    1. Google Geocoding API
    2. HTML5 Geolocation API
    3. Other Use Cases
  3. Privacy Requirements

Contribute to Recommending API Profiles

In order to build profiles and benefit from the recommendation, every implementation must contribute to collecting location data through users’ digital journey.

Synchronous and Asynchronous

Like described in the Loading topic, use the corresponding method depending on how you loaded the recommendation.js script.

//Synchronous
woosmapRecommendation.sendUserHtml5Position({lat: 43, lng: 3.3});

//Asynchronous
rRequestQueue.push(['sendUserHtml5Position', [{lat: 43, lng: 3.3}]]);

Contributing Use Cases

Google Geocoding API

Below is a sample HTML and Javascript code to allow your visitor to geocode an address. The resulted position will be pushed to Woosmap Profile using woosmapRecommendation.sendUserSearchedPosition()

<input type="text" name="query" id="queryinput" placeholder="Search an Address">
<input type="submit" id="search-geocoding">
<script>
function geocodeAddress(geocoder) {
    var address = document.getElementById('queryinput').value;
    geocoder.geocode({'address': address}, function (results, status) {
        if (status === google.maps.GeocoderStatus.OK) {
            var latitude = results[0].geometry.location.lat();
            var longitude = results[0].geometry.location.lng();
            //Contribute to Woosmap Profile
            woosmapRecommendation.sendUserSearchedPosition({
                lat: latitude,
                lng: longitude,
                successCallback: function () {
                    // finally, search the assets around your location
                    searchWoosmapApiAroundLocation(latitude, longitude);
                }
            });
        } else {
            console.log('Geocode was not successful: ' + status);
        }
    });
}
function init() {
    var geocoder = new google.maps.Geocoder();
    document.getElementById('search-geocoding').addEventListener('click',
        function () {
            geocodeAddress(geocoder);
        });
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=API_KEY&callback=init">
</script>

HTML5 Geolocation API

The Geolocation API, natively supported by modern browsers, defines a high-level interface to location information associated only with the device hosting the implementation, such as latitude and longitude. Here is a Javascript sample to plug this feature to your website and contribute to Woosmap profiles on success callback using woosmapRecommendation.sendUserHtml5Position().

// Acquire a new position object.
navigator.geolocation.getCurrentPosition(successCallback, errorCallback);

function successCallback(position) {
    //Contribute to Woosmap Profile
    woosmapRecommendation.sendUserHtml5Position({
        lat: position.coords.latitude,
        lng: position.coords.longitude,
        successCallback: function () {
            // finally, search the assets around your location
            searchWoosmapApiAroundLocation(latitude, longitude);
        }
    })
}

function errorCallback(error) {
    console.log(error.code)
}

Other Use Cases

You are able to contribute in many other instances like posting the user billing position or a shipping position. Please refer to the API Reference for an exhaustive list of all the ways such contributing could be posted.

Privacy Requirements

Woosmap takes privacy very seriously. In order to be compliant with standard reglementation on data privacy, a website using Woosmap Recommendation must add to its privacy policy the following mention: