title: Changing Source url of a XYZ layer and redrawing the layer/map?
body: <p>I wanna change the url of my ol3 map source. I've tryed using things such as map.set or map.getlayers().set or whatever but I can't seem to find a way to access my source object. Here's the code: </p>
  
  <pre><code>function init() {
      var map = new ol.Map({
          target: 'map',
          layers: [
              new ol.layer.Tile({
                  source: new ol.source.XYZ({
                      projection: 'PIXELS',
                      tileGrid: mapTileGrid,
                      url: loc
                  })
              })
          ],
          view: new ol.View({
              projection: ol.proj.get('PIXELS'),
              extent: mapExtent,
               maxResolution: mapTileGrid.getResolution(0)
               })
          });
  
  map.getView().fit(mapExtent, map.getSize());
      console.log(map.get("layergroup").get("layers").get("url"));
      map.get("layergroup").get("layers").set("url",loc);
  }
  </code></pre>
  
  <p>What's a way to change the url property and reload the layer ?</p>
  
  <p>I also tried using the setSource function as in the following answer : <a href="https://stackoverflow.com/questions/20260620/openlayers-3-and-xyz-layer">here</a>
  but it seems to not work (can't setSource of undefined).</p>