private void Start()
 {
     OnlineMaps api = OnlineMaps.instance;
     marker = api.AddMarker(api.position);
     fromPosition = api.topLeftPosition;
     toPosition = api.bottomRightPosition;
 }
	    // Use this for initialization
	    private void Start ()
        {
            marker = OnlineMaps.instance.AddMarker(Vector2.zero, "Hello World");
            marker.OnDrawTooltip = delegate {  };

            OnlineMaps.instance.OnUpdateLate += OnUpdateLate;
        }
        private void Start()
        {
            // Create a new marker.
            marker = OnlineMaps.instance.AddMarker(new Vector2(), "Player");

            // Subscribe to UpdateBefore event.
            OnlineMaps.instance.OnUpdateBefore += OnUpdateBefore;
        }
예제 #4
0
	void Start ()
	{
        // Create a new marker.
        playerMarker = OnlineMaps.instance.AddMarker(new Vector2(0, 0), null, "Player");

        // Get instance of LocationService.
	    OnlineMapsLocationService locationService = GetComponent<OnlineMapsLocationService>();

        // Subscribe to the change location event.
        locationService.OnLocationChanged += OnLocationChanged;
	}
        private void DrawBoxAroundMarker(OnlineMapsMarker marker)
        {
            // Get screen rect of marker
            Rect rect = marker.realScreenRect;

            // Convert Input coordinates to GUI coordinates
            rect.y = Screen.height - rect.y;
            rect.height *= -1;

            // Draw box
            GUI.Box(rect, new GUIContent());
        }
    /// <summary>
    /// Creates a new instance of the billboard marker.
    /// </summary>
    /// <param name="marker">Marker</param>
    /// <returns>Instance of billboard marker</returns>
    public static OnlineMapsMarkerBillboard Create(OnlineMapsMarker marker)
    {
        GameObject billboardGO = new GameObject("Marker");
        SpriteRenderer spriteRenderer = billboardGO.AddComponent<SpriteRenderer>();
        OnlineMapsMarkerBillboard billboard = billboardGO.AddComponent<OnlineMapsMarkerBillboard>();

        billboard.marker = marker;
        Texture2D texture = marker.texture;
        if (marker.texture == null) texture = OnlineMaps.instance.defaultMarkerTexture;
        if (texture != null) spriteRenderer.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0));

        return billboard;
    }
 private float OnGetFlatMarkerOffsetY(OnlineMapsMarker marker)
 {
     if (marker == mapMarkerTop)
     {
         return(1);
     }
     if (marker == mapMarkerMiddle)
     {
         return(0.5f);
     }
     if (marker == mapMarkerBottom)
     {
         return(0);
     }
     return(0);
 }
예제 #8
0
    private void updateMarker(double lng, double lat, int gpsID, string timeStr)
    {
        Dictionary <int, OnlineMapsMarker> markersDict = GPSInfosManager.Insatance.markersDict;

        if (markersDict.ContainsKey(gpsID))
        {
            OnlineMapsMarker m = markersDict[gpsID];
            m.SetPosition(lng, lat);
            m.label = gpsID + " " + timeStr;
        }
        else
        {
            OnlineMapsMarker m = OnlineMapsMarkerManager.CreateItem(lng, lat, gpsID + " " + timeStr);
            markersDict.Add(gpsID, m);
        }
    }
        private void Start()
        {
            OnlineMaps api = OnlineMaps.instance;

            // Create a new markers.
            OnlineMapsMarker marker1 = api.AddMarker(new Vector2(0, 0), null, "Marker 1");
            OnlineMapsMarker marker2 = api.AddMarker(new Vector2(10, 0), null, "Marker 2");

            // Store data about labels.
            marker1.customData = new ShowMarkerLabelsByZoomItem(marker1.label, new OnlineMapsRange(3, 10));
            marker2.customData = new ShowMarkerLabelsByZoomItem(marker2.label, new OnlineMapsRange(8, 15));

            // Sunscribe to ChangeZoom event.
            api.OnChangeZoom += OnChangeZoom;
            OnChangeZoom();
        }
예제 #10
0
    private void OnInitComplete(OnlineMapsMarkerBase markerBase)
    {
        OnlineMapsMarker marker         = markerBase as OnlineMapsMarker;
        Texture2D        texture        = marker.texture;
        SpriteRenderer   spriteRenderer = GetComponent <SpriteRenderer>();

        if (marker.texture == null)
        {
            texture = OnlineMapsMarkerManager.instance.defaultTexture;
        }
        if (texture != null)
        {
            spriteRenderer.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0));
            spriteRenderer.flipX  = true;
        }
    }
        private void Start()
        {
            OnlineMaps map = OnlineMaps.instance;

            // Create a new markers.
            OnlineMapsMarker marker1 = OnlineMapsMarkerManager.CreateItem(new Vector2(0, 0), null, "Marker 1");
            OnlineMapsMarker marker2 = OnlineMapsMarkerManager.CreateItem(new Vector2(10, 0), null, "Marker 2");

            // Store data about labels.
            marker1["data"] = new ShowMarkerLabelsByZoomItem(marker1.label, new OnlineMapsRange(3, 10));
            marker2["data"] = new ShowMarkerLabelsByZoomItem(marker2.label, new OnlineMapsRange(8, 15));

            // Sunscribe to ChangeZoom event.
            map.OnChangeZoom += OnChangeZoom;
            OnChangeZoom();
        }
예제 #12
0
    void LocationUpdate()
    {
        Debug.Log("\t\tLocation update round");
        // Debug.Log ("\t\t MAP == " + map);

        using (UnityWebRequest locReq = SendLocationsRequest()) {
            LocationEntity[] locations;
            locReq.SendWebRequest();
            while (!locReq.isDone)
            {
            }
            if (locReq.error != null)
            {
                Debug.Log("\t\t" + "Transmission error for locations \n" + locReq.error);
                loadingText.text = "Ошибка передачи данных локаций \n" + locReq.error;
                return;
            }
            else
            {
                string result = locReq.downloadHandler.text;
                // Debug.Log ("LOCATIONS RESULT: |" + result + "|");
                locations = JsonHelper.getJsonArray <LocationEntity> (result);
                markers   = new List <OnlineMapsMarker> ();

                for (int i = 0; i < locations.Length; i++)
                {
                    // Debug.Log ("PROCESSING MARKER FOR " + locations [i].name);
                    OnlineMapsMarker marker = new OnlineMapsMarker();
                    marker.SetPosition(locations [i].longitude, locations [i].latitude);
                    marker.label = locations [i].name;
                    markers.Add(marker);
                }


                for (int i = 0; i < map.markers.Length; i++)
                {
                    if (map.markers[i].label != "Текущая Позиция")
                    {
                        map.RemoveMarker(map.markers [i], true);
                    }
                }

                Debug.Log("ADDING LOCATION MARKERS");
                markers.ForEach(marker => map.AddMarker(marker));
            }
        }
    }
예제 #13
0
    private Rect GetMarkerRect(OnlineMapsMarker marker)
    {
        const int s = OnlineMapsUtils.tileSize;

        double mx, my;

        marker.GetPosition(out mx, out my);

        double tx, ty;

        api.projection.CoordinatesToTile(mx, my, bufferZoom, out tx, out ty);
        tx -= bufferPosition.x;
        ty -= bufferPosition.y;
        OnlineMapsVector2i ip = marker.GetAlignedPosition(new OnlineMapsVector2i((int)(tx * s), (int)(ty * s)));

        return(new Rect(ip.x, ip.y, marker.width, marker.height));
    }
        private bool TryRemoveMarker(OnlineMapsMarker marker)
        {
            for (int i = 0; i < count; i++)
            {
                ClusterItem item = childs[i];
                if (item is Cluster)
                {
                    if ((item as Cluster).TryRemoveMarker(marker))
                    {
                        return(true);
                    }
                }
                else if (item.markerRef == marker)
                {
                    item.Dispose();
                    for (int j = i; j < count - 1; j++)
                    {
                        childs[j] = childs[j + 1];
                    }
                    count--;
                    totalCount--;

                    Cluster p = parent;
                    while (p != null)
                    {
                        p.totalCount--;
                        p.Update();
                        p = p.parent;
                    }

                    childs[count] = null;

                    if (count == 1 && parent != null)
                    {
                        if (childs[0] is MarkerWrapper)
                        {
                            parent.Replace(this, childs[0] as MarkerWrapper);
                            Dispose();
                        }
                    }

                    return(true);
                }
            }
            return(false);
        }
예제 #15
0
        private void Start()
        {
            // Create a new marker.
            playerMarker = OnlineMaps.instance.AddMarker(new Vector2(0, 0), null, "Player");

            // Get instance of LocationService.
            OnlineMapsLocationService locationService = OnlineMapsLocationService.instance;

            if (locationService == null)
            {
                Debug.LogError(
                    "Location Service not found.\nAdd Location Service Component (Component / Infinity Code / Online Maps / Plugins / Location Service).");
                return;
            }

            // Subscribe to the change location event.
            locationService.OnLocationChanged += OnLocationChanged;
        }
    public virtual IOnlineMapsInteractiveElement GetInteractiveElement(Vector2 screenPosition)
    {
        if (IsCursorOnUIElement(screenPosition))
        {
            return(null);
        }

        OnlineMapsMarker marker = markerDrawer.GetMarkerFromScreen(screenPosition);

        if (marker != null)
        {
            return(marker);
        }

        OnlineMapsDrawingElement drawingElement = map.GetDrawingElement(screenPosition);

        return(drawingElement);
    }
예제 #17
0
    private static void LoadMarkers(OnlineMapsXML el, OnlineMaps api)
    {
        List <OnlineMapsMarker> markers = new List <OnlineMapsMarker>();

        foreach (OnlineMapsXML m in el)
        {
            OnlineMapsMarker marker = new OnlineMapsMarker();
            marker.position = m.Get <Vector2>("Position");
            marker.range    = m.Get <OnlineMapsRange>("Range");
            marker.label    = m.Get <string>("Label");
            marker.texture  = GetObject(m.Get <int>("Texture")) as Texture2D;
            marker.align    = (OnlineMapsAlign)m.Get <int>("Align");
            marker.rotation = m.Get <float>("Rotation");
            markers.Add(marker);
        }

        api.markers = markers.ToArray();
    }
예제 #18
0
    /// <summary>
    /// Creates a marker at the location of the cursor.
    /// </summary>
    protected void CreateMarker()
    {
        OnlineMapsMarker m = new OnlineMapsMarker
        {
            position = GetCoords(),
            texture  = api.defaultMarkerTexture
        };

        m.Init();

        if (api.markers == null)
        {
            api.markers = new OnlineMapsMarker[0];
        }
        Array.Resize(ref api.markers, api.markers.Length + 1);
        api.markers[api.markers.Length - 1] = m;
        api.Redraw();
    }
예제 #19
0
        private void OnMouseUp()
        {
            if (Input.GetKey(KeyCode.LeftShift))
            {
                // Get the geographical coordinates of the cursor.
                Vector2 cursorCoords = map.control.GetCoords();

                // Create a new marker at the specified coordinates.
                OnlineMapsMarker marker = map.AddMarker(cursorCoords, markerTexture, "Marker " + (map.markers.Length + 1));

                // Save marker and coordinates.
                markerPositions.Add(cursorCoords);
                markers.Add(marker);

                // Mark that markers changed.
                changed = true;
            }
        }
        private void Start()
        {
            OnlineMaps api = OnlineMaps.instance;

            mapMarkerMiddle = api.AddMarker(new Vector2(0, 0));
            mapMarkerTop    = api.AddMarker(new Vector2(0, 0.01f));
            mapMarkerBottom = api.AddMarker(new Vector2(0, -0.01f));

            OnlineMapsTileSetControl.instance.markerComparer = new MarkerComparer();

            Vector2 center;
            int     zoom;

            OnlineMapsUtils.GetCenterPointAndZoom(api.markers, out center, out zoom);

            api.position = center;
            api.zoom     = zoom;
        }
        private void Start()
        {
            // Create a new marker.
            playerMarker = OnlineMaps.instance.AddMarker(new Vector2(0, 0), null, "Player");

            // Get instance of LocationService.
            OnlineMapsLocationService locationService = OnlineMapsLocationService.instance;

            if (locationService == null)
            {
                Debug.LogError(
                    "Location Service not found.\nAdd Location Service Component (Component / Infinity Code / Online Maps / Plugins / Location Service).");
                return;
            }

            // Subscribe to the change location event.
            locationService.OnLocationChanged += OnLocationChanged;
        }
예제 #22
0
    private void OnInitComplete(OnlineMapsMarkerBase markerBase)
    {
        OnlineMapsMarker marker         = markerBase as OnlineMapsMarker;
        Texture2D        texture        = marker.texture;
        SpriteRenderer   spriteRenderer = GetComponent <SpriteRenderer>();

        if (marker.texture == null)
        {
            texture = OnlineMaps.instance.defaultMarkerTexture;
        }
        if (texture != null)
        {
            spriteRenderer.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0));
#if !UNITY_4_6 && !UNITY_4_7 && !UNITY_5_0 && !UNITY_5_1 && !UNITY_5_2
            spriteRenderer.flipX = true;
#endif
        }
    }
예제 #23
0
    private void DrawMarkerGUI(int i, ref int index, ref bool hasDeleted)
    {
        EditorGUILayout.BeginVertical(GUI.skin.box);

        OnlineMapsMarker marker = api.markers[i];

        GUILayout.Label("Marker " + index);

        EditorGUI.BeginChangeCheck();
        marker.position.y = EditorGUILayout.FloatField("Latitude: ", marker.position.y);
        marker.position.x = EditorGUILayout.FloatField("Longitude: ", marker.position.x);

        float min = marker.range.min;
        float max = marker.range.max;

        EditorGUILayout.MinMaxSlider(new GUIContent(string.Format("Zooms ({0}-{1}): ", marker.range.min, marker.range.max)), ref min, ref max, 3, 20);
        marker.range.min = Mathf.RoundToInt(min);
        marker.range.max = Mathf.RoundToInt(max);

        marker.range.min = Mathf.Clamp(marker.range.min, 3, 20);
        marker.range.max = Mathf.Clamp(marker.range.max, 3, 20);

        marker.rotation = Mathf.Repeat(EditorGUILayout.FloatField("Rotation (0-1): ", marker.rotation), 1);
        marker.label    = EditorGUILayout.TextField("Label: ", marker.label);
        marker.align    = (OnlineMapsAlign)EditorGUILayout.EnumPopup("Align: ", marker.align);
        marker.texture  =
            (Texture2D)EditorGUILayout.ObjectField("Texture: ", marker.texture, typeof(Texture2D), true);

        if (EditorGUI.EndChangeCheck() && Application.isPlaying)
        {
            api.Redraw();
        }

        CheckMarkerTextureImporter(marker.texture);

        if (GUILayout.Button("Remove"))
        {
            api.markers[i] = null;
            hasDeleted     = true;
        }
        index++;

        EditorGUILayout.EndVertical();
    }
예제 #24
0
    private void GetStoresCatalogDelegate(MeridianData.Stores inStores)
    {
        if (inStores != null)
        {
            stores = inStores;

            foreach (MeridianData.Store store in inStores.storeList)
            {
                OnlineMapsMarker marker = OnlineMaps.instance.AddMarker(float.Parse(store.Longitud), float.Parse(store.Latitud), store.Tienda.TrimEnd());
                marker.scale = 0.5f;

                // uGUICustomMarkerEngineExample.AddMarker(float.Parse(store.Longitud), float.Parse(store.Latitud), store.Tienda.TrimEnd());
            }

            Debug.Log(inStores.storeList.Length + " Stores got");

            UpdateClosestStores(userCoordinates);
        }
    }
예제 #25
0
    /// <summary>
    /// Creates a new instance of the billboard marker.
    /// </summary>
    /// <param name="marker">Marker</param>
    /// <returns>Instance of billboard marker</returns>
    public static OnlineMapsMarkerBillboard Create(OnlineMapsMarker marker)
    {
        GameObject                billboardGO    = new GameObject("Marker");
        SpriteRenderer            spriteRenderer = billboardGO.AddComponent <SpriteRenderer>();
        OnlineMapsMarkerBillboard billboard      = billboardGO.AddComponent <OnlineMapsMarkerBillboard>();

        billboard.marker = marker;
        Texture2D texture = marker.texture;

        if (marker.texture == null)
        {
            texture = OnlineMaps.instance.defaultMarkerTexture;
        }
        if (texture != null)
        {
            spriteRenderer.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0));
        }

        return(billboard);
    }
 public bool UpdateMarker(OnlineMapsMarker marker)
 {
     for (int i = 0; i < count; i++)
     {
         ClusterItem item = childs[i];
         if (item is Cluster)
         {
             if ((item as Cluster).UpdateMarker(marker))
             {
                 return(true);
             }
         }
         else if (item.markerRef == marker)
         {
             (item as MarkerWrapper).UpdatePosition();
             return(true);
         }
     }
     return(false);
 }
    private IEnumerator GenerateMarkers(float timeToWait)
    {
        yield return(new WaitForSeconds(timeToWait));

        Resources.UnloadUnusedAssets();


        var objectList  = LoadJSONFromHTML();
        var startTime   = Stopwatch.StartNew();
        var objectCount = objectList.Length;


        for (var i = 0; i < objectCount; i++)
        {
            var obj = objectList[i];
            if (obj.production == null || obj.production.location == null || obj.production.location.Length == 0)
            {
                continue;
            }
            var lt = obj.production.location[0].lat;
            var lg = obj.production.location[0].@long;


            OnlineMapsMarker marker = OnlineMapsMarkerManager.CreateItem(lg, lt);
            marker.label = obj.label != null && obj.label.Length > 0 ? obj.label[0] : obj.identifier;

            marker.Init();

            marker.OnPositionChanged += delegate(OnlineMapsMarkerBase m)
            {
                Clustering2DMarkers.UpdateMarkerPosition(m as OnlineMapsMarker);
            };

            Clustering2DMarkers.Add(marker);
        }

        Debug.Log("Antes de UpdatePositions: " + (startTime.ElapsedMilliseconds * 0.001f) + " segundos");
        Clustering2DMarkers.UpdatePositions();

        Debug.Log("CARGAR TODOS LOS OBJETOS: " + (startTime.ElapsedMilliseconds * 0.001f) + " segundos");
    }
예제 #28
0
    public void Check()
    {
        //RequestSimpleResult result;
        //result = UpdateInfo(currentGame, currentPoint, true, false, true, true);

        if (isGame)
        {
            CheckResult resultCheck = Check(currentGame, map.position.y, map.position.x);
            if (resultCheck.point != -1)
            {
                resultGeneral.text = string.Format("Point {0} was found!", curreintPointIndex + 1);
                OnlineMapsMarker m = markers[resultCheck.point];
                m.SetPosition(resultCheck.lon, resultCheck.lat);
                map.Redraw();
                Debug.Log("R");
                Debug.Log(resultCheck.point);
                SetQuestion(resultCheck.point);
                if (resultCheck.point == 0)
                {
                    resultMiniGame.First = true;
                }
                if (resultCheck.point == 1)
                {
                    resultMiniGame.Second = true;
                }
                if (resultCheck.point == 2)
                {
                    resultMiniGame.Third = true;
                }
                if (resultCheck.point == 3)
                {
                    resultMiniGame.Fourth = true;
                }
                if (resultMiniGame.First && resultMiniGame.Second && resultMiniGame.Third && resultMiniGame.Fourth)
                {
                    isGame             = false;
                    resultGeneral.text = "You are a winner!";
                }
            }
        }
    }
예제 #29
0
    public MapPointMarker(float longitud, float latitud, GameObject prefabObject, bool cluster) : base(longitud, latitud)
    {
        //Debug.Log("Longi,Lat --> " + longitud+","+latitud);


        marker3D = OnlineMapsMarker3DManager.CreateItem(new Vector2(longitud, latitud), prefabObject);
        if (marker3D != null)
        {
            marker3D.transform.name = this.label;
        }

        marker2D = OnlineMapsMarkerManager.CreateItem(new Vector2(longitud, latitud), "");

        this.cluster = cluster;

        /*if (this.cluster)
         * {
         *  if (marker3D != null) marker3D.DestroyInstance();
         *  marker3D = null;
         * }*/

        this.initData();

        if (marker2D != null)
        {
            marker2D.OnClick += OnMarkerClick;
            if (dimension == MapPoint.THREE_DIMENSION)
            {
                marker2D.enabled = false;
            }
        }

        if (marker3D != null)
        {
            marker3D.OnClick += OnMarkerClick;
            if (dimension == MapPoint.TWO_DIMENSION)
            {
                marker3D.enabled = false;
            }
        }
    }
예제 #30
0
        private void Start()
        {
            // Create a new markers.
            OnlineMapsMarker marker1 = OnlineMaps.instance.AddMarker(Vector2.zero, "Marker 1");
            OnlineMapsMarker marker2 = OnlineMaps.instance.AddMarker(new Vector2(10, 0), "Marker 2");

            // Create new XML and store it in customData.
            OnlineMapsXML xml1 = new OnlineMapsXML("MarkerData");

            xml1.Create("ID", "marker1");
            marker1.customData = xml1;

            OnlineMapsXML xml2 = new OnlineMapsXML("MarkerData");

            xml2.Create("ID", "marker2");
            marker2.customData = xml2;

            // Subscribe to click event.
            marker1.OnClick += OnMarkerClick;
            marker2.OnClick += OnMarkerClick;
        }
예제 #31
0
    public PlayBackExecutor(List <OnlineMapsVector2d> _points, string label)
    {
        points = _points;
        OnlineMaps.instance.SetPosition(points[0].x, points[0].y);

        routeLen     = points.Count;
        fromPosition = points[0];
        toPosition   = points[1];
        routeIndex   = 1;
        // Draw the route.
        OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(points);

        route.color = Color.yellow;
        route.width = 1;

        OnlineMapsDrawingElementManager.AddItem(route);

        marker = OnlineMapsMarkerManager.CreateItem(points[0], label);

        isRun = true;
    }
        public MarkerWrapper FindMarkerWrapper(OnlineMapsMarker marker)
        {
            for (int i = 0; i < count; i++)
            {
                ClusterItem item = childs[i];
                if (item is Cluster)
                {
                    MarkerWrapper wrapper = (item as Cluster).FindMarkerWrapper(marker);
                    if (wrapper != null)
                    {
                        return(wrapper);
                    }
                }
                else if (item.markerRef == marker)
                {
                    return(item as MarkerWrapper);
                }
            }

            return(null);
        }
    public static void UpdateMarkers()
    {
        double tlx, tly, brx, bry;

        GetCorners(out tlx, out tly, out brx, out bry);

        if (markers == null)
        {
            markers = new List <OnlineMapsMarker>();
        }
        rootCluster.GetMarkers(tlx, tly, brx, bry, ref markers);
        markers.AddRange(unclusteredMarkers);

        OnlineMapsMarker[] prevMarkers = OnlineMapsMarkerManager.instance.items.ToArray();
        OnlineMapsMarker[] newMarkers  = markers.ToArray();
        markers.Clear();

        for (int i = 0; i < prevMarkers.Length; i++)
        {
            OnlineMapsMarker m = prevMarkers[i];

            for (int j = 0; j < newMarkers.Length; j++)
            {
                OnlineMapsMarker m2 = newMarkers[j];
                if (m == m2)
                {
                    break;
                }
            }
        }

        OnlineMapsMarkerManager.SetItems(newMarkers);

        double tx, ty;

        map.GetTilePosition(out tx, out ty);
        mapTileX   = (int)tx;
        mapTileY   = (int)ty;
        needUpdate = false;
    }
예제 #34
0
    public override IOnlineMapsInteractiveElement GetInteractiveElement(Vector2 screenPosition)
    {
        #if !IGUI && ((!UNITY_ANDROID && !UNITY_IOS) || UNITY_EDITOR)
        if (map.notInteractUnderGUI && GUIUtility.hotControl != 0)
        {
            return(null);
        }
#endif

        if (EventSystem.current != null)
        {
            PointerEventData pe = new PointerEventData(EventSystem.current);
            pe.position = screenPosition;
            List <RaycastResult> hits = new List <RaycastResult>();
            EventSystem.current.RaycastAll(pe, hits);
            if (hits.Count > 0 && hits[0].gameObject != gameObject)
            {
                return(null);
            }
        }

        RaycastHit hit;
        if (Physics.Raycast(activeCamera.ScreenPointToRay(screenPosition), out hit, OnlineMapsUtils.maxRaycastDistance))
        {
            OnlineMapsMarkerInstanceBase markerInstance = hit.collider.gameObject.GetComponent <OnlineMapsMarkerInstanceBase>();
            if (markerInstance != null)
            {
                return(markerInstance.marker);
            }
        }

        OnlineMapsMarker marker = map.GetMarkerFromScreen(screenPosition);
        if (marker != null)
        {
            return(marker);
        }

        OnlineMapsDrawingElement drawingElement = map.GetDrawingElement(screenPosition);
        return(drawingElement);
    }
 private void UpdateMarker()
 {
     if (_marker == null)
     {
         if (markerType == OnlineMapsLocationServiceMarkerType.twoD)
         {
             OnlineMapsMarker m2d = OnlineMapsMarkerManager.CreateItem(position, marker2DTexture, markerTooltip);
             _marker   = m2d;
             m2d.align = marker2DAlign;
             m2d.scale = markerScale;
             if (useCompassForMarker)
             {
                 m2d.rotationDegree = trueHeading;
             }
         }
         else
         {
             OnlineMapsControlBase3D control = map.control as OnlineMapsControlBase3D;
             if (control == null)
             {
                 Debug.LogError("You must use the 3D control (Texture or Tileset).");
                 createMarkerInUserPosition = false;
                 return;
             }
             OnlineMapsMarker3D m3d = OnlineMapsMarker3DManager.CreateItem(position, marker3DPrefab);
             _marker      = m3d;
             m3d.sizeType = marker3DSizeType;
             m3d.scale    = markerScale;
             m3d.label    = markerTooltip;
             if (useCompassForMarker)
             {
                 m3d.rotationY = trueHeading;
             }
         }
     }
     else
     {
         _marker.position = position;
     }
 }
예제 #36
0
    /// <summary>
    /// Creates a new instance of the billboard marker.
    /// </summary>
    /// <param name="marker">Marker</param>
    /// <returns>Instance of billboard marker</returns>
    public static OnlineMapsMarkerBillboard Create(OnlineMapsMarker marker)
    {
        GameObject                billboardGO    = new GameObject("Marker");
        SpriteRenderer            spriteRenderer = billboardGO.AddComponent <SpriteRenderer>();
        OnlineMapsMarkerBillboard billboard      = billboardGO.AddComponent <OnlineMapsMarkerBillboard>();

        billboard.marker       = marker;
        marker.OnInitComplete += billboard.OnInitComplete;
        Texture2D texture = marker.texture;

        if (marker.texture == null)
        {
            texture = (marker.manager as OnlineMapsMarkerManager).defaultTexture;
        }
        if (texture != null)
        {
            spriteRenderer.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0));
            spriteRenderer.flipX  = true;
        }

        return(billboard);
    }
예제 #37
0
        private void Start()
        {
            Resources.UnloadUnusedAssets();
            markers = new List <OnlineMapsMarker>();


            var startTime = Stopwatch.StartNew();

            var objectList = LoadJSONFromHTML();

            foreach (var obj in objectList)
            {
                if (obj.production == null || obj.production.location == null || obj.production.location.Length == 0)
                {
                    continue;
                }
                var lat = obj.production.location[0].lat;
                var lg  = obj.production.location[0].@long;

                //if (string.IsNullOrEmpty(lat) || string.IsNullOrEmpty(lg))
                //    continue;

                var longitud = lg;  //float.Parse(lg);
                var latitud  = lat; //float.Parse(lat);



                OnlineMapsMarker marker = OnlineMapsMarkerManager.CreateItem(new Vector2(longitud, latitud));
                marker.label = (obj.label != null && obj.label.Length > 0) ? obj.label[0] : obj.identifier;
                markers.Add(marker);
            }

            // Group markers.
            GroupMarkers();
            Debug.Log("CARGAR TODOS LOS OBJETOS: " + (startTime.ElapsedMilliseconds / 100.0) + " segundos");
            GC.Collect();
            Debug.Log("Memoria total: " + (GC.GetTotalMemory(false) / 1000000.0));
            Resources.UnloadUnusedAssets();
        }
예제 #38
0
    private static void Load(OnlineMaps api)
    {
        api.position = LoadPref("Position", api.position);
        api.zoom = LoadPref("Zoom", api.zoom);
        api.provider = (OnlineMapsProviderEnum) LoadPref("Provider", 0);
        api.customProviderURL = LoadPref("CustomProviderURL", "http://localhost/{zoom}/{y}/{x}");
        api.type = LoadPref("Type", 0);
        api.labels = LoadPref("Labels", false);

        api.markers = new OnlineMapsMarker[LoadPref("Marker_Count", 0)];
        for (int i = 0; i < api.markers.Length; i++)
        {
            OnlineMapsMarker marker = new OnlineMapsMarker();
            marker.position = LoadPref("Marker_" + i + "_Position", marker.position);
            marker.range = LoadPref("Marker_" + i + "_Range", marker.range);
            int mid = LoadPref("Marker_" + i + "_Texture", 0);
            if (mid != 0) marker.texture = EditorUtility.InstanceIDToObject(mid) as Texture2D;
            marker.label = LoadPref("Marker_" + i + "_Label", marker.label);
            marker.align = (OnlineMapsAlign) LoadPref("Marker_" + i + "_Align", (int) marker.align);
            api.markers[i] = marker;
        }

        OnlineMapsTextureControl control = api.gameObject.GetComponent<OnlineMapsTextureControl>();
        if (control != null)
        {
            control.markers3D = new OnlineMapsMarker3D[LoadPref("Marker3D_Count", 0)];
            for (int i = 0; i < control.markers3D.Length; i++)
            {
                OnlineMapsMarker3D marker = new OnlineMapsMarker3D();
                marker.position = LoadPref("Marker3D_" + i + "_Position", marker.position);
                marker.range = LoadPref("Marker3D_" + i + "_Range", marker.range);
                Debug.Log(marker.range);
                int mid = LoadPref("Marker3D_" + i + "_Prefab", 0);
                marker.prefab = EditorUtility.InstanceIDToObject(mid) as GameObject;
                marker.label = LoadPref("Marker3D_" + i + "_Label", marker.label);
                control.markers3D[i] = marker;
            }
        }
    }
        private void OnComplete(string response)
        {
            Debug.Log("OnComplete");
            List<OnlineMapsDirectionStep> steps = OnlineMapsDirectionStep.TryParse(response);
            if (steps == null)
            {
                Debug.Log("Something wrong");
                Debug.Log(response);
                return;
            }

            // Create a new marker in first point.
            marker = OnlineMaps.instance.AddMarker(steps[0].start, "Car");

            // Gets points of route.
            points = OnlineMapsDirectionStep.GetPoints(steps);

            // Draw the route.
            OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(points, Color.red, 3);
            OnlineMaps.instance.AddDrawingElement(route);

            pointIndex = 0;
        }
예제 #40
0
    /// <summary>
    /// Checks if the marker in the specified screen coordinates, and shows him a tooltip.
    /// </summary>
    /// <param name="screenPosition">Screen coordinates</param>
    public void ShowMarkersTooltip(Vector2 screenPosition)
    {
        if (showMarkerTooltip != OnlineMapsShowMarkerTooltip.onPress)
        {
            tooltip = string.Empty;
            tooltipDrawingElement = null;
            tooltipMarker = null;
        }

        if (control is OnlineMapsControlBase3D && OnlineMapsControlBase3D.instance.marker2DMode == OnlineMapsMarker2DMode.billboard)
        {
            return;
        }

        OnlineMapsMarker marker = GetMarkerFromScreen(screenPosition);

        if (showMarkerTooltip == OnlineMapsShowMarkerTooltip.onHover)
        {
            if (marker != null)
            {
                tooltip = marker.label;
                tooltipMarker = marker;
            }
            else
            {
                OnlineMapsDrawingElement drawingElement = GetDrawingElement(screenPosition);
                if (drawingElement != null)
                {
                    tooltip = drawingElement.tooltip;
                    tooltipDrawingElement = drawingElement;
                }
            }
        }

        if (rolledMarker != marker)
        {
            if (rolledMarker != null && rolledMarker.OnRollOut != null) rolledMarker.OnRollOut(rolledMarker);
            rolledMarker = marker;
            if (rolledMarker != null && rolledMarker.OnRollOver != null) rolledMarker.OnRollOver(rolledMarker);
        }
    }
예제 #41
0
    /// <summary>
    /// Function that is called when you release the map.
    /// </summary>
    protected void OnMapBaseRelease()
    {
        if (!allowUserControl) return;

        bool isClick = (pressPoint - Input.mousePosition).magnitude < 20;
        isMapDrag = false;
        dragMarker = null;

        if (longPressEnumenator != null)
        {
#if !UNITY_3_5 && !UNITY_3_5_5
            StopCoroutine(longPressEnumenator);
#else
            StopCoroutine("WaitLongPress");
#endif
            longPressEnumenator = null;
        }

        OnlineMaps.isUserControl = false;
        if (OnMapRelease != null) OnMapRelease();

        OnlineMapsMarker marker = api.GetMarkerFromScreen(GetCoords());

        if (marker != null)
        {
            if (marker.OnRelease != null) marker.OnRelease(marker);
            if (isClick && marker.OnClick != null) marker.OnClick(marker);
        }

        if (isClick && DateTime.Now.Ticks - lastClickTimes[0] < 5000000)
        {
            if (marker != null && marker.OnDoubleClick != null) marker.OnDoubleClick(marker);
            else
            {
                if (OnMapDoubleClick != null) OnMapDoubleClick();

                if (allowZoom && zoomInOnDoubleClick) ZoomOnPoint(1, Input.mousePosition);
            }
            
            lastClickTimes[0] = 0;
            lastClickTimes[1] = 0;
        }

        if (api.bufferStatus == OnlineMapsBufferStatus.wait) api.needRedraw = true;
    }
 public void Add(OnlineMapsMarker marker)
 {
     markers.Add(marker);
     center = markers.Aggregate(Vector2.zero, (current, m) => current + m.position) / markers.Count;
     instance.position = center;
     tilePosition = OnlineMapsUtils.LatLongToTilef(center, zoom);
     instance.label = "Group. Count: " + markers.Count;
 }
예제 #43
0
 /// <summary>
 /// Adds a 2D marker on the map.
 /// </summary>
 /// <param name="marker">
 /// The marker you want to add.
 /// </param>
 /// <returns>
 /// Marker instance.
 /// </returns>
 public OnlineMapsMarker AddMarker(OnlineMapsMarker marker)
 {
     List<OnlineMapsMarker> ms = markers.ToList();
     marker.Init();
     ms.Add(marker);
     markers = ms.ToArray();
     needRedraw = allowRedraw = true;
     return marker;
 }
예제 #44
0
    /// <summary>
    /// Get the center point and best zoom for the array of markers.
    /// </summary>
    /// <param name="markers">Array of markers.</param>
    /// <param name="center">Center point.</param>
    /// <param name="zoom">Best zoom.</param>
    public static void GetCenterPointAndZoom(OnlineMapsMarker[] markers, out Vector2 center, out int zoom)
    {
        float minX = Single.MaxValue;
        float minY = Single.MaxValue;
        float maxX = Single.MinValue;
        float maxY = Single.MinValue;

        foreach (OnlineMapsMarker marker in markers)
        {
            if (marker.position.x < minX) minX = marker.position.x;
            if (marker.position.y < minY) minY = marker.position.y;
            if (marker.position.x > maxX) maxX = marker.position.x;
            if (marker.position.y > maxY) maxY = marker.position.y;
        }

        float rx = maxX - minX;
        float ry = maxY - minY;
        center = new Vector2(rx / 2 + minX, ry / 2 + minY);

        int width = OnlineMaps.instance.width;
        int height = OnlineMaps.instance.height;

        float countX = width / (float)tileSize / 2;
        float countY = height / (float)tileSize / 2;

        for (int z = 20; z > 4; z--)
        {
            bool success = true;

            foreach (OnlineMapsMarker marker in markers)
            {
                Vector2 p = LatLongToTilef(marker.position, z);
                Vector2 bufferPosition = LatLongToTilef(center, z);
                p.x -= bufferPosition.x - countX;
                p.y -= bufferPosition.y - countY;
                OnlineMapsVector2i ip = marker.GetAlignedPosition(new OnlineMapsVector2i((int)(p.x * tileSize), (int)(p.y * tileSize)));
                if (ip.x < 0 || ip.y < 0 || ip.x + marker.width > width || ip.y + marker.height > height)
                {
                    success = false;
                    break;
                }
            }
            if (success)
            {
                zoom = z - 1;
                return;
            }
        }

        zoom = 3;
    }
예제 #45
0
    /// <summary>
    /// Adds a new 2D marker on the map.
    /// </summary>
    /// <param name="markerPosition">X - Longituge. Y - Latitude.</param>
    /// <param name="markerTexture">
    /// <strong>Optional</strong><br/>
    /// Marker texture. <br/>
    /// In import settings must be enabled "Read / Write enabled". <br/>
    /// Texture format: ARGB32. <br/>
    /// If not specified, the will be used default marker texture.</param>
    /// <param name="label">
    /// <strong>Optional</strong><br/>
    /// The text that will be displayed when you hover a marker.</param>
    /// <returns>Marker instance.</returns>
    public OnlineMapsMarker AddMarker(Vector2 markerPosition, Texture2D markerTexture = null, string label = "")
    {
        if (markerTexture == null) markerTexture = defaultMarkerTexture;

        List<OnlineMapsMarker> ms = markers.ToList();
        OnlineMapsMarker marker = new OnlineMapsMarker
        {
            position = markerPosition,
            texture = markerTexture,
            label = label,
            align = defaultMarkerAlign
        };
        marker.Init();
        ms.Add(marker);
        markers = ms.ToArray();
        needRedraw = allowRedraw = true;
        return marker;
    }
예제 #46
0
 /// <summary>
 /// Adds a 2D markers on the map.
 /// </summary>
 /// <param name="newMarkers">
 /// The markers.
 /// </param>
 public void AddMarkers(OnlineMapsMarker[] newMarkers)
 {
     List<OnlineMapsMarker> ms = markers.ToList();
     foreach (OnlineMapsMarker marker in newMarkers)
     {
         marker.Init();
         ms.Add(marker);
     }
     markers = ms.ToArray();
     needRedraw = allowRedraw = true;
 }
예제 #47
0
    private static void LoadMarkers(OnlineMapsXML el, OnlineMaps api)
    {
        List<OnlineMapsMarker> markers = new List<OnlineMapsMarker>();

        foreach (OnlineMapsXML m in el)
        {
            OnlineMapsMarker marker = new OnlineMapsMarker();
            marker.position = m.Get<Vector2>("Position");
            marker.range = m.Get<OnlineMapsRange>("Range");
            marker.label = m.Get<string>("Label");
            marker.texture = GetObject(m.Get<int>("Texture")) as Texture2D;
            marker.align = (OnlineMapsAlign)m.Get<int>("Align");
            marker.rotation = m.Get<float>("Rotation");
            markers.Add(marker);
        }

        api.markers = markers.ToArray();
    }
예제 #48
0
    private void OnGUIMarkers()
    {
        if (api.markers == null) api.markers = new OnlineMapsMarker[0];
        if (GUILayout.Button("Add marker"))
        {
            OnlineMapsMarker marker = new OnlineMapsMarker {position = api.position};
            List<OnlineMapsMarker> markers = new List<OnlineMapsMarker>(api.markers) {marker};
            api.markers = markers.ToArray();
        }

        int index = 1;
        bool hasDeleted = false;

        for (int i = 0; i < api.markers.Length; i++) OnGUIMarker(i, ref index, ref hasDeleted);

        if (hasDeleted)
        {
            List<OnlineMapsMarker> markers = api.markers.ToList();
            markers.RemoveAll(m => m == null);
            api.markers = markers.ToArray();
        }

        EditorGUILayout.Space();
    }
예제 #49
0
    /// <summary>
    /// Function that is called when you press the map.
    /// </summary>
    protected void OnMapBasePress()
    {
        if (!allowUserControl) return;

        dragMarker = null;
        if (HitTest())
        {
            if (OnMapPress != null) OnMapPress();

            lastClickTimes[0] = lastClickTimes[1];
            lastClickTimes[1] = DateTime.Now.Ticks;
            lastPosition = GetCoords();
            pressPoint = Input.mousePosition;
            if (lastPosition == Vector2.zero) return;

            OnlineMapsMarker marker = api.GetMarkerFromScreen(lastPosition);
            if (marker != null)
            {
                if (marker.OnPress != null) marker.OnPress(marker);
                if (Input.GetKey(KeyCode.LeftControl)) dragMarker = marker;
            }

            if (dragMarker == null)
            {
                isMapDrag = true;
                longPressEnumenator = WaitLongPress();
                StartCoroutine(longPressEnumenator);
            }
            else lastClickTimes[0] = 0;

            OnlineMaps.isUserControl = true;
        }
    }
예제 #50
0
	public void AddMarker (float longitude, float latitude)
	{
		OnlineMapsMarker marker = new OnlineMapsMarker ();
		marker.position = new Vector2 (longitude,latitude);
		map.AddMarker(marker);
		map.Redraw ();
	}
예제 #51
0
    private void SetMarkerToBuffer(OnlineMapsMarker marker, Vector2 startPos, Vector2 endPos)
    {
        const int s = OnlineMapsUtils.tileSize;
        float mx = marker.position.x;
        if (!(((mx > startPos.x && mx < endPos.x) || (mx + 360 > startPos.x && mx + 360 < endPos.x) ||
             (mx - 360 > startPos.x && mx - 360 < endPos.x)) &&
            marker.position.y < startPos.y && marker.position.y > endPos.y)) return;

#if !UNITY_WEBGL
        int maxCount = 20;
        while (marker.locked && maxCount > 0)
        {
            Thread.Sleep(1);
            maxCount--;
        }
#endif

        marker.locked = true;
        Vector2 p = OnlineMapsUtils.LatLongToTilef(marker.position, bufferZoom);
        p -= bufferPosition;

        int maxX = 1 << bufferZoom;

        if (p.x < 0) p.x += maxX;
        else if (p.x > maxX) p.x -= maxX;

        OnlineMapsVector2i ip = marker.GetAlignedPosition(new OnlineMapsVector2i((int) (p.x * s), (int) (p.y * s)));

        Color[] markerColors = marker.colors;
        if (markerColors == null || markerColors.Length == 0) return;

        int markerWidth = marker.width;
        int markerHeight = marker.height;

        for (int y = 0; y < marker.height; y++)
        {
            if (ip.y + y < 0 || ip.y + y >= height) continue;

            int my = (markerHeight - y - 1) * markerWidth;
            
            for (int x = 0; x < marker.width; x++)
            {
                if (ip.x + x < 0 || ip.x + x >= width) continue;
            
                try
                {
                    SetColorToBuffer(markerColors[my + x], ip, y, x);
                }
                catch
                {
                }
            }
        }

        marker.locked = false;
    }
    private void Start()
    {
        rwt = GetComponent<RealWorldTerrainContainer>();
        if (rwt == null)
        {
            Debug.LogError("Real World Terrain Connector should be together c Real World Terrain Container.");
            DestroyImmediate(this);
            return;
        }

        if (positionMode == OnlineMapsRWTConnectorPositionMode.transform && targetTransform == null)
        {
            Debug.LogError("Target Transform is not specified.");
            DestroyImmediate(this);
            return;
        }

        api = OnlineMaps.instance;

        if (mode == OnlineMapsRWTConnectorMode.centerOnPosition)
        {
            api.position = currentPosition;
        }
        else if (mode == OnlineMapsRWTConnectorMode.markerOnPosition)
        {
            marker = api.AddMarker(currentPosition, markerTexture, markerLabel);
        }
    }
 public MarkerGroup(int zoom, Texture2D texture)
 {
     markers = new List<OnlineMapsMarker>();
     this.zoom = zoom;
     instance = OnlineMaps.instance.AddMarker(Vector2.zero, texture);
     instance.align = OnlineMapsAlign.Center;
     instance.range = new OnlineMapsRange(zoom, zoom);
 }
예제 #54
0
    private void SetMarkerToBuffer(OnlineMapsMarker marker, Vector2 startPos, Vector2 endPos)
    {
        const int s = OnlineMapsUtils.tileSize;
        float mx = marker.position.x;
        if (((mx > startPos.x && mx < endPos.x) || (mx + 360 > startPos.x && mx + 360 < endPos.x) ||
             (mx - 360 > startPos.x && mx - 360 < endPos.x)) &&
            marker.position.y < startPos.y && marker.position.y > endPos.y)
        {
            while (marker.locked) Thread.Sleep(1);

            marker.locked = true;
            Vector2 p = OnlineMapsUtils.LatLongToTilef(marker.position, bufferZoom);
            p -= bufferPosition;
            OnlineMapsVector2i ip =
                marker.GetAlignedPosition(new OnlineMapsVector2i((int) (p.x * s), (int) (p.y * s)));

            Color[] markerColors = marker.colors;
            if (markerColors == null || markerColors.Length == 0) return;
            for (int x = 0; x < marker.width; x++)
            {
                if (ip.x + x < 0 || ip.x + x >= width) continue;
                for (int y = 0; y < marker.height; y++)
                {
                    if (ip.y + y < 0 || ip.y + y >= height) continue;
                    try
                    {
                        SetColorToBuffer(markerColors[(marker.height - y - 1) * marker.width + x], ip, y, x);
                    }
                    catch
                    {
                    }
                }
            }

            marker.locked = false;
        }
    }
예제 #55
0
 private Rect GetMarkerRect(OnlineMapsMarker marker)
 {
     const int s = OnlineMapsUtils.tileSize;
     Vector2 p = OnlineMapsUtils.LatLongToTilef(marker.position, bufferZoom);
     p.x -= bufferPosition.x;
     p.y -= bufferPosition.y;
     OnlineMapsVector2i ip = marker.GetAlignedPosition(new OnlineMapsVector2i((int)(p.x * s), (int)(p.y * s)));
     return new Rect(ip.x, ip.y, marker.width, marker.height);
 }
 public TilesetFlatMarker(OnlineMapsMarker marker, Vector3 p1, Vector3 p2)
 {
     this.marker = marker;
     rect = new Rect(p1.x, p1.z, p1.x - p2.x, p2.z - p1.z);
     rect.x -= rect.width;
 }
 /// <summary>
 /// Creates a marker at the location of the cursor.
 /// </summary>
 protected void CreateMarker()
 {
     OnlineMapsMarker m = new OnlineMapsMarker
     {
         position = GetCoords(),
         texture = api.defaultMarkerTexture
     };
     m.Init();
     List<OnlineMapsMarker> markerList = api.markers.ToList();
     markerList.Add(m);
     api.markers = markerList.ToArray();
     api.Redraw();
 }
예제 #58
0
	public void AddMarker (OnlineMapsMarker _marker,float longitude, float latitude,string label)
	{
		OnlineMapsMarker marker = new OnlineMapsMarker ();
		marker.texture = _marker.texture;
		marker.label = label;
		marker.position = new Vector2 (longitude,latitude);
		map.AddMarker(marker);
		map.Redraw ();
	}
예제 #59
0
    private void DrawMarkersGUI()
    {
        if (api.markers == null) api.markers = new OnlineMapsMarker[0];

        int index = 1;
        bool hasDeleted = false;

        for (int i = 0; i < api.markers.Length; i++) DrawMarkerGUI(i, ref index, ref hasDeleted);

        if (hasDeleted)
        {
            List<OnlineMapsMarker> markers = api.markers.ToList();
            markers.RemoveAll(m => m == null);
            api.markers = markers.ToArray();
            if (Application.isPlaying) api.Redraw();
        }

        EditorGUILayout.Space();

        if (GUILayout.Button("Add marker"))
        {
            if (!Application.isPlaying)
            {
                OnlineMapsMarker marker = new OnlineMapsMarker { position = api.position, align = api.defaultMarkerAlign };
                List<OnlineMapsMarker> markers = new List<OnlineMapsMarker>(api.markers) { marker };
                api.markers = markers.ToArray();
            }
            else
            {
                OnlineMapsMarker marker = api.AddMarker(api.position);
                marker.align = api.defaultMarkerAlign;
            }
        }
    }
예제 #60
0
 /// <summary>
 /// Remove the specified 2D marker from the map.
 /// </summary>
 /// <param name="marker">2D marker you want to remove.</param>
 public void RemoveMarker(OnlineMapsMarker marker)
 {
     List<OnlineMapsMarker> ms = markers.ToList();
     ms.Remove(marker);
     markers = ms.ToArray();
     Redraw();
 }