<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Using OpenSeaMap in Online Maps]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=2107&amp;type=atom" />
	<updated>2023-04-13T07:00:04Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=2107</id>
		<entry>
			<title type="html"><![CDATA[Re: Using OpenSeaMap in Online Maps]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=8958#p8958" />
			<content type="html"><![CDATA[<p>It works, thank you very much!</p>]]></content>
			<author>
				<name><![CDATA[renem]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2569</uri>
			</author>
			<updated>2023-04-13T07:00:04Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=8958#p8958</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Using OpenSeaMap in Online Maps]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=8956#p8956" />
			<content type="html"><![CDATA[<p>Example:<br /></p><div class="codebox"><pre><code>using System;
using UnityEngine;

namespace InfinityCode.OnlineMapsSupport
{
    public class OpenSeaMapLayer : MonoBehaviour
    {
        // Overlay transparency
        [Range(0, 1)]
        public float alpha = 1;
    
        private float _alpha = 1;
    
        private void LoadTileOverlay(OnlineMapsTile tile)
        {
     
            var url = &quot;https://tiles.openseamap.org/seamark/&quot; + tile.zoom + &quot;/&quot; + tile.x + &quot;/&quot; + tile.y + &quot;.png&quot;;
    
            OnlineMapsWWW www = new OnlineMapsWWW(url);
            www.OnComplete += OnDownloadComplete;
            www.customFields[&quot;tile&quot;] = tile;
        }
    
        private void OnDownloadComplete(OnlineMapsWWW www)
        {
            OnlineMapsTile tile = www.customFields[&quot;tile&quot;] as OnlineMapsTile;
            if (tile == null || tile.status == OnlineMapsTileStatus.disposed || tile.status == OnlineMapsTileStatus.error) return;
    
            Texture2D texture = new Texture2D(256, 256);
            www.LoadImageIntoTexture(texture);
            tile.overlayBackTexture = texture;
        }
    
        private void OnStartDownloadTile(OnlineMapsTile tile)
        {
            tile.status = OnlineMapsTileStatus.loading;
    
            // Load overlay for tile.
            LoadTileOverlay(tile);
    
            // Load the tile using a standard loader.
            OnlineMapsTileManager.StartDownloadTile(tile);
    
        }
    
        private void Start()
        {
            if (OnlineMapsCache.instance != null)
            {
                // Subscribe to the cache events.
                OnlineMapsCache.instance.OnLoadedFromCache += LoadTileOverlay;
            }
    
            OnlineMapsTileManager.OnStartDownloadTile += OnStartDownloadTile;
        }
    
        private void Update()
        {
            // Update the transparency of overlay.
            if (Math.Abs(_alpha - alpha) &gt; float.Epsilon)
            {
                _alpha = alpha;
                lock (OnlineMapsTile.lockTiles)
                {
                    foreach (OnlineMapsTile tile in OnlineMaps.instance.tileManager.tiles) tile.overlayBackAlpha = alpha;
                }
            }
        }
    }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2023-04-12T11:25:55Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=8956#p8956</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Using OpenSeaMap in Online Maps]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=8955#p8955" />
			<content type="html"><![CDATA[<p>Thank you for the quick reply,<br />i use OnlineMaps in Unity3D, but i don&#039;t know exactly how to set the provider to use OpenSeaMap maps. Can you give me an example?<br />Source: online<br />Provider: custom(?)<br />Custom provider url: <a href="http://map.openseamap.org/">http://map.openseamap.org/</a> (?)<br />Kind regards</p>]]></content>
			<author>
				<name><![CDATA[renem]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2569</uri>
			</author>
			<updated>2023-04-12T11:14:03Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=8955#p8955</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Using OpenSeaMap in Online Maps]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=8953#p8953" />
			<content type="html"><![CDATA[<p>Hi.</p><p>Yes, you can use the OpenSeaMap.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2023-04-12T10:04:34Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=8953#p8953</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Using OpenSeaMap in Online Maps]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=8951#p8951" />
			<content type="html"><![CDATA[<p>Hello everyone,<br />is it possible to use the maps from OpenSeaMap, has anyone had experience with this?<br />Thanks in advance.<br />Dear greetings</p>]]></content>
			<author>
				<name><![CDATA[renem]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2569</uri>
			</author>
			<updated>2023-04-12T09:02:38Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=8951#p8951</id>
		</entry>
</feed>
