private void UpdateMarker(uGUICustomMarkerExample marker)
        {
            OnlineMaps api = OnlineMaps.instance;
            Vector2 pos = marker.position;
            Vector2 tl = api.topLeftPosition;
            Vector2 br = api.bottomRightPosition;

            if (pos.x < tl.x || pos.x > br.x || pos.y < br.y || pos.y > tl.y)
            {
                marker.gameObject.SetActive(false);
                return;
            }

            Vector2 screenPosition = OnlineMapsControlBase.instance.GetScreenPosition(pos);

            RectTransform markerRectTransform = marker.transform as RectTransform;

            if (!marker.gameObject.activeSelf)
            {
                marker.gameObject.SetActive(true);
            }

            screenPosition.y += markerRectTransform.rect.height / 2;

            Vector2 point;
            RectTransformUtility.ScreenPointToLocalPointInRectangle(markerRectTransform.parent as RectTransform, screenPosition, null, out point);
            markerRectTransform.localPosition = point;
        }
Example #2
0
        public static uGUICustomMarkerExample AddMarker(double lng, double lat, string text)
        {
            GameObject markerGameObject = Instantiate(_instance.markerPrefab) as GameObject;

            (markerGameObject.transform as RectTransform).SetParent(_instance.markerContainer);
            markerGameObject.transform.localScale = Vector3.one;
            uGUICustomMarkerExample marker = markerGameObject.GetComponent <uGUICustomMarkerExample>();

            if (marker == null)
            {
                marker = markerGameObject.AddComponent <uGUICustomMarkerExample>();
            }

            marker.text = text;
            marker.lng  = lng;
            marker.lat  = lat;

            markers.Add(marker);
            _instance.UpdateMarker(marker);
            return(marker);
        }
Example #3
0
        private void UpdateMarker(uGUICustomMarkerExample marker)
        {
            double tlx, tly, brx, bry;

            int countX = map.width / OnlineMapsUtils.tileSize;
            int countY = map.height / OnlineMapsUtils.tileSize;

            double px, py;

            map.projection.CoordinatesToTile(map.buffer.apiPosition.x, map.buffer.apiPosition.y, map.buffer.apiZoom, out px, out py);

            px -= countX / 2f;
            py -= countY / 2f;

            map.projection.TileToCoordinates(px, py, map.buffer.apiZoom, out tlx, out tly);

            px += countX;
            py += countY;

            map.projection.TileToCoordinates(px, py, map.buffer.apiZoom, out brx, out bry);

            UpdateMarker(marker, tlx, tly, brx, bry);
        }
 public static void RemoveMarker(uGUICustomMarkerExample marker)
 {
     OnlineMapsUtils.DestroyImmediate(marker.gameObject);
     marker.Dispose();
     markers.Remove(marker);
 }