<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Center map at specific screen point]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1070&amp;type=atom" />
	<updated>2019-03-25T17:20:17Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=1070</id>
		<entry>
			<title type="html"><![CDATA[Re: Center map at specific screen point]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4702#p4702" />
			<content type="html"><![CDATA[<p>Okay, that answer wasn&#039;t really helpful, but I figured out how to do it. I had to calculate the offset between the marker and the screen point, then position the map accordingly.</p><p>In case someone else needs this: </p><div class="codebox"><pre><code>public void CenterMapAtScreenPoint(Vector2 markerCoordinates, Vector3 _positionOfScreenPoint, float? _zoom = null)
    {
        // center the marker
        OnlineMaps.instance.SetPositionAndZoom(markerCoordinates.x, markerCoordinates.y, _zoom);

        // get coordinates of the ScreenPoint
        Vector2 screenPointCoordinates = OnlineMapsControlBase.instance.GetCoords(_positionOfScreenPoint);

        // calculate offset between marker and ScreenPoint
        float targetCoordsX = (float)(markerCoordinates.x  - (markerCoordinates.x  - screenPointCoordinates.x));
        float targetCoordsY = (float)(markerCoordinates.y + (markerCoordinates.y - screenPointCoordinates.y));

        // move map
        OnlineMaps.instance.SetPositionAndZoom(targetCoordsX, targetCoordsY, _zoom);
    }</code></pre></div>]]></content>
			<author>
				<name><![CDATA[MartinTinu]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=915</uri>
			</author>
			<updated>2019-03-25T17:20:17Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4702#p4702</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Center map at specific screen point]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4698#p4698" />
			<content type="html"><![CDATA[<p>OnlineMaps.SetPosition or OnlineMaps.SetPositionAndZoom.<br /><a href="http://infinity-code.com/doxygen/online-maps/classOnlineMaps.html#a1aa95950865ecec7677236e65d01d9b7">http://infinity-code.com/doxygen/online … e65d01d9b7</a></p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2019-03-25T15:18:35Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4698#p4698</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Center map at specific screen point]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4697#p4697" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Alex Vertax wrote:</cite><blockquote><p>... and set these coordinates to a map.</p></blockquote></div><p>That&#039;s the point I don&#039;t know how to achieve. <img src="https://forum.infinity-code.com/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /></p>]]></content>
			<author>
				<name><![CDATA[MartinTinu]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=915</uri>
			</author>
			<updated>2019-03-25T14:09:31Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4697#p4697</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Center map at specific screen point]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4696#p4696" />
			<content type="html"><![CDATA[<p>Hello.</p><p>Convert the screen position into geographic coordinates using OnlineMapsControlBase.GetCoords, and set these coordinates to a map.<br /><a href="http://infinity-code.com/doxygen/online-maps/classOnlineMapsControlBase.html#a2a7adafc4273a14dc2ae0ad0a0d3ee6f">http://infinity-code.com/doxygen/online … d0a0d3ee6f</a></p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2019-03-25T13:54:22Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4696#p4696</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Center map at specific screen point]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=4695#p4695" />
			<content type="html"><![CDATA[<p>Hello there!</p><p>SetPositionAndZoom() centers a location. Is it possible to center it at a custom screen point?<br />Something like<br /><strong>SetPositionAndZoomToScreenPoint( double lng, double lat, float? zoom, Vector2 screenPoint ){...}</strong></p><p>Problem in our application is, that the target point is not the center of the map (see image).<br />Any way to achieve this? <img src="https://forum.infinity-code.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>Best,<br />Martin</p>]]></content>
			<author>
				<name><![CDATA[MartinTinu]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=915</uri>
			</author>
			<updated>2019-03-25T12:26:49Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=4695#p4695</id>
		</entry>
</feed>
