<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — How can I reload the map?]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=666</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=666&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in How can I reload the map?.]]></description>
		<lastBuildDate>Fri, 29 Sep 2017 23:55:54 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: How can I reload the map?]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2866#p2866</link>
			<description><![CDATA[<p>Hello.</p><p>How to reload all tiles:<br /></p><div class="codebox"><pre><code>foreach (OnlineMapsTile tile in OnlineMapsTile.tiles) tile.Dispose();
OnlineMapsTile.tiles.Clear();
OnlineMaps.instance.Redraw();</code></pre></div><p>But keep in mind - if you use the cache, then the texture that is already in the cache will be loaded. <br />You can read - the wrong textures will be loaded.</p><p>I recently made this script for another user.<br />Most likely you also want to do something like this:<br /></p><div class="codebox"><pre><code>using System;
using System.Reflection;
using UnityEngine;

public class ChangeCustomStyle2:MonoBehaviour
{
    public string style1;
    public string style2;

    private bool useFirstStyle = true;

    private void OnGUI()
    {
        if (GUILayout.Button(&quot;Change Style&quot;))
        {
            useFirstStyle = !useFirstStyle;
            OnlineMaps.instance.mapType = &quot;myprovider.style&quot; + (useFirstStyle? &quot;1&quot;: &quot;2&quot;);
        }
    }

    private void Start()
    {
        // Online Maps v2.5.17 or less
        ConstructorInfo constructor = typeof(OnlineMapsProvider).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new[]{typeof(string)}, null);
        OnlineMapsProvider provider = (OnlineMapsProvider)constructor.Invoke(new []{&quot;myprovider&quot;});

        OnlineMapsProvider.MapType[] types =
        {
            new OnlineMapsProvider.MapType(&quot;style1&quot;)
            {
                urlWithLabels = style1,
                provider = provider,
                fullID = &quot;myprovider.style1&quot;
            },
            new OnlineMapsProvider.MapType(&quot;style2&quot;)
            {
                urlWithLabels = style2,
                provider = provider,
                fullID = &quot;myprovider.style2&quot;
            }
        };

        OnlineMapsProvider[] providers = OnlineMapsProvider.GetProviders();
        Array.Resize(ref providers, providers.Length + 1);
        providers[providers.Length - 1] = provider;

        typeof(OnlineMapsProvider).GetField(&quot;_types&quot;, BindingFlags.NonPublic | BindingFlags.Instance).SetValue(provider, types);
        typeof(OnlineMapsProvider).GetField(&quot;providers&quot;, BindingFlags.NonPublic | BindingFlags.Static).SetValue(null, providers);

        // Online Maps v2.5.18+
        /*OnlineMapsProvider.Create(&quot;myprovider&quot;).AppendTypes(
            new OnlineMapsProvider.MapType(&quot;style1&quot;) { urlWithLabels = style1, },
            new OnlineMapsProvider.MapType(&quot;style2&quot;) { urlWithLabels = style2, }
        );*/

        OnlineMaps.instance.mapType = &quot;myprovider.style1&quot;;
    }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 29 Sep 2017 23:55:54 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2866#p2866</guid>
		</item>
		<item>
			<title><![CDATA[How can I reload the map?]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=2859#p2859</link>
			<description><![CDATA[<p>I am using a custom tile source, and I would like to be able to change the URL within the application and reload the tiles, but I cannot find anything in the API that is obvious for this and the few things that I have tried (such as clearing the OnlineMapsTile.tiles collection) haven&#039;t worked.</p><p>Specifically: I can change the URL but cannot figure out how to tell the map to reload the tiles from the new source.&nbsp; Any help you can provide would be appreciated!</p>]]></description>
			<author><![CDATA[null@example.com (tcepsa)]]></author>
			<pubDate>Fri, 29 Sep 2017 18:41:48 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=2859#p2859</guid>
		</item>
	</channel>
</rss>
