<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><font face="Helvetica, Arial, sans-serif">Hi Roman,</font></p>
<p><font face="Helvetica, Arial, sans-serif">you are absolutely
right and your explanation brings it to the point. I wasn't
aware that the '</font><font face="Helvetica, Arial, sans-serif">tileUrlFunction'
should not be overwritten </font><font face="Helvetica, Arial,
sans-serif"><font face="Helvetica, Arial, sans-serif">directly</font>.
I changed my code according to your suggestion it works perfectly.</font></p>
<p><font face="Helvetica, Arial, sans-serif">Thanks you very much!
Great help!<br>
</font></p>
<p><font face="Helvetica, Arial, sans-serif">Cheers<br>
Chris</font><br>
</p>
<br>
<div class="moz-cite-prefix">On 12.10.2017 14:48, Roman Zoller
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAN_28KeestDA=_zu8z_nAp+pRDwRrziyXrhACYq=j5+4dhsQzg@mail.gmail.com">
<div dir="ltr">As far as I understand, the ol.source.VectorTile
class wasn't specifically designed to have tileUrlFunction as a
function that can be overriden and that will be called with a
specific this context.
<div><br>
</div>
<div>I think the general idea is that you can just pass any
function as options.tileUrlFunction, and it just happened to
be called with a this context of the class before version
4.2.0, but I guess this was never really an intended feature.</div>
<div><br>
</div>
<div>For your specific issue, I think you could rename the
function in your class to avoid confusion, e.g.</div>
<div><br>
</div>
<div>
<div>ol.source.GWCVT.prototype.defaultTileUrlFunction =</div>
<div> function(tileCoord, pixelRatio, projection) {</div>
</div>
<div> // ...</div>
<div>};</div>
<div><br>
</div>
<div>and then pass it as options.tileUrlFunction to the super
class in your constructor, with correctly bound this:</div>
<div><br>
</div>
<div>
<div>ol.source.GWCVT = function(options) {</div>
<div> var tileUrlFunction = options.tileUrlFunction ||
this.defaultTileUrlFunction.bind(this);</div>
<div><br>
</div>
<div> ol.source.VectorTile.call(this, {</div>
<div> tileUrlFunction: tileUrlFunction,</div>
<div> ...</div>
<div> });</div>
<div>};</div>
</div>
<div><br>
</div>
<div>Hope that helps!</div>
<div><br>
</div>
<div>Cheers,</div>
<div><br>
</div>
<div>Roman</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Oct 12, 2017 at 2:33 PM,
Christian Mayer <span dir="ltr"><<a
href="mailto:ml-cm@meggsimum.de" target="_blank"
moz-do-not-send="true">ml-cm@meggsimum.de</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<p><font face="Helvetica, Arial, sans-serif">Hi again,<br>
</font></p>
<p><font face="Helvetica, Arial, sans-serif">here is some
more information in addition to my previous mail:</font></p>
<p><font face="Helvetica, Arial, sans-serif">The problem
occurs for VectorTiles in GeoJSON format as well. So
there must be a more general problem with extending
the </font><br>
<font face="Helvetica, Arial, sans-serif">ol.source.VectorTile
(or the way I do it).<br>
The change / problem seems to be introduced with
Version 4.2.0. With version 4.1.1 everything works as
expected.</font></p>
<p><font face="Helvetica, Arial, sans-serif">Cheers<br>
Chris<br>
</font></p>
<div>
<div class="h5">
<p><br>
</p>
<div class="m_-5162081911146622419moz-cite-prefix">On
12.10.2017 13:45, Christian Mayer wrote:<br>
</div>
</div>
</div>
<blockquote type="cite">
<div>
<div class="h5">
<p><font face="Helvetica, Arial, sans-serif">Hi all,</font></p>
<p>I extended the class ol.source.VectorTile in
order to load VectorTiles in different formats
(GeoJSON and MVT) from a local GWC cache. While
upgrading from OpenLayers v3.20 to OpenLayers v4.x
it seems that for MVT the scope in the
"tileUrlFunction" gets lost. It seems to be
"window". For GeoJSON-based VectorTiles everything
is still running fine.</p>
<p>Below you find the crutial parts of my class:</p>
<p><tt>ol.inherits(ol.source.GWCVT,
ol.source.VectorTile);</tt><tt><br>
</tt><tt><br>
</tt><tt>ol.source.GWCVT.prototype.<wbr>tileUrlFunction
=</tt><tt><br>
</tt><tt> function(tileCoord, pixelRatio,
projection) {</tt></p>
<p><tt>// here 'this' becomes 'window' in the second
call<br>
</tt></p>
<p><tt>// assembling the URL</tt><tt><br>
</tt><tt>// ...</tt><tt><br>
</tt></p>
<p><tt>}</tt></p>
<p><tt>ol.source.GWCVT.prototype.<wbr>setTileUrlFunction
= function(tileUrlFunction) {</tt><tt><br>
</tt><tt><br>
</tt><tt> ol.source.VectorTile.<wbr>prototype.setTileUrlFunction.<wbr>call(this,
tileUrlFunction);</tt><tt><br>
</tt><tt>};</tt></p>
<p>Thanks for any hint!</p>
Cheers<br>
Chris <br>
<fieldset
class="m_-5162081911146622419mimeAttachmentHeader"></fieldset>
<br>
</div>
</div>
<pre>______________________________<wbr>_________________
Dev mailing list
<a class="m_-5162081911146622419moz-txt-link-abbreviated" href="mailto:Dev@lists.osgeo.org" target="_blank" moz-do-not-send="true">Dev@lists.osgeo.org</a>
<a class="m_-5162081911146622419moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/openlayers-dev" target="_blank" moz-do-not-send="true">https://lists.osgeo.org/<wbr>mailman/listinfo/openlayers-<wbr>dev</a></pre>
</blockquote>
<br>
</div>
<br>
______________________________<wbr>_________________<br>
Dev mailing list<br>
<a href="mailto:Dev@lists.osgeo.org" moz-do-not-send="true">Dev@lists.osgeo.org</a><br>
<a
href="https://lists.osgeo.org/mailman/listinfo/openlayers-dev"
rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.osgeo.org/<wbr>mailman/listinfo/openlayers-<wbr>dev</a><br>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>