Beispiel #1
0
    private void DrawGeneralGUI(ref bool dirty)
    {
        DrawSourceGUI(ref dirty);
        DrawLocationGUI(ref dirty);
        DrawTargetGUI();

        if (OnlineMaps.isPlaying)
        {
            if (GUILayout.Button("Redraw"))
            {
                map.Redraw();
            }

            DrawCacheGUI(ref dirty);

            if (!showSave)
            {
                if (GUILayout.Button("Save state"))
                {
                    showSave = true;
                    dirty    = true;
                }
            }
            else
            {
                DrawSaveGUI(ref dirty);
            }
        }
    }
Beispiel #2
0
 public void LockPositionClick(OnlineMapsOSMNominatimResult data)
 {
     SetSearchMarker(data.location, data.display_name);
     if (_api.zoom < 13)
     {
         _api.zoom = 13;
     }
     _api.position = data.location;
     _api.Redraw();
 }
    private void OnDisable()
    {
        foreach (OnlineMapsTile tile in OnlineMapsTile.tiles)
        {
            tile.overlayFrontTexture = null;
        }

        if (map != null)
        {
            map.Redraw();
        }
    }
    private void OnDisable()
    {
        foreach (OnlineMapsTile tile in OnlineMapsTile.tiles)
        {
            SetOverlay(tile as OnlineMapsRasterTile, null);
        }

        if (map != null)
        {
            map.Redraw();
        }
    }
Beispiel #5
0
    private void UpdateMarkerRotation()
    {
        if (!useCompassForMarker || marker == null)
        {
            return;
        }

        float value;

        if (markerType == OnlineMapsLocationServiceMarkerType.twoD)
        {
            value = (_marker as OnlineMapsMarker).rotation * 360;
        }
        else
        {
            value = (_marker as OnlineMapsMarker3D).rotationY;
        }

        if (trueHeading - value > 180)
        {
            value += 360;
        }
        else if (trueHeading - value < -180)
        {
            value -= 360;
        }

        if (Math.Abs(trueHeading - value) >= float.Epsilon)
        {
            if (Mathf.Abs(trueHeading - value) < 0.003f)
            {
                value = trueHeading;
            }
            else
            {
                value = Mathf.Lerp(value, trueHeading, 0.02f);
            }

            if (markerType == OnlineMapsLocationServiceMarkerType.twoD)
            {
                (_marker as OnlineMapsMarker).rotation = value / 360;
            }
            else
            {
                (_marker as OnlineMapsMarker3D).rotationY = value;
            }

            api.Redraw();
        }
    }
 private void OnDisable()
 {
     if (map != null)
     {
         if (map.tileManager != null && map.tileManager.tiles != null)
         {
             foreach (OnlineMapsTile tile in map.tileManager.tiles)
             {
                 SetOverlay(tile as OnlineMapsRasterTile, null);
             }
         }
         map.Redraw();
     }
 }
    /// <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();
    }
    public void OncenterClick(int id)
    {
        Vector2 position = Datacenter.instance.listCenter[id].pos;

        if (position != Vector2.zero)
        {
            if (_searchMarker == null)
            {
                _searchMarker = _api.AddMarker(position);
            }
            else
            {
                _searchMarker.position = position;
                _searchMarker.label    = "center Localtion";
            }

            if (_api.zoom < 10)
            {
                _api.zoom = 10;
            }

            _api.position = position;
            _api.Redraw();
            ChooseCenter = id;
        }
        else
        {
            Debug.Log("Please Open services");
        }
    }
Beispiel #9
0
    public override void OnInspectorGUI()
    {
        bool dirty = false;

        DrawSettings(ref dirty);
        DrawItems(ref dirty);

        if (GUILayout.Button("Add Marker"))
        {
            AddMarker();
            dirty = true;
        }

        serializedObject.ApplyModifiedProperties();

        if (dirty)
        {
            EditorUtility.SetDirty(target);
            if (!Application.isPlaying)
            {
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
            }
            else
            {
                map.Redraw();
            }
        }
    }
Beispiel #10
0
    public void OncenterClick(int id)
    {
        Vector2 position = Datacenter.instance.listCenter[id].pos;

        if (position != Vector2.zero)
        {
            if (_searchMarker == null)
            {
                _searchMarker = _api.AddMarker(position);
            }
            else
            {
                _searchMarker.position = position;
                _searchMarker.label    = "center Localtion";
            }

            if (_api.zoom < 13)
            {
                _api.zoom = 13;
            }

            _api.position = position;
            _api.Redraw();
        }
    }
Beispiel #11
0
    public void SetMarkers(Marker[] markers)
    {
        onlineMap.RemoveAllMarkers();
        if (markers != null)
        {
            for (int i = 0; i < markers.Length; i++)
            {
                OnlineMapsMarker mark = new OnlineMapsMarker();
                mark.position = markers[i].geoPos;
                //mark.label = markers[i].label;
                mark.OnClick    = OnClickMark;
                mark.customData = markers[i];
                mark.texture    = markTexture;
                onlineMap.AddMarker(mark);
            }
        }

        if (GeoLocation.posicaoEncontrada)
        {
            OnlineMapsMarker me = new OnlineMapsMarker();
            me.position = GeoLocation.position;
            me.texture  = myPositionTexture;
            onlineMap.AddMarker(me);

            onlineMap.Redraw();
        }
    }
Beispiel #12
0
        private void OnFindLocationComplete(string result)
        {
            Vector2 position = OnlineMapsGoogleGeocoding.GetCoordinatesFromResult(result);

            if (position == Vector2.zero)
            {
                return;
            }

            if (searchMarker == null)
            {
                searchMarker = api.AddMarker(position, search);
            }
            else
            {
                searchMarker.position = position;
                searchMarker.label    = search;
            }

            if (api.zoom < 13)
            {
                api.zoom = 13;
            }

            api.position = position;
            api.Redraw();
        }
    /// <summary>
    /// Moves the marker to the location of the cursor.
    /// </summary>
    protected void DragMarker()
    {
        double lat, lng;
        bool   hit = GetCoords(out lng, out lat);

        if (hit)
        {
            double offsetX = lng - lastPositionLng;
            double offsetY = lat - lastPositionLat;

            if (offsetX != 0 || offsetY != 0)
            {
                double px, py;
                dragMarker.GetPosition(out px, out py);

                px = px + offsetX;
                py = py + offsetY;

                dragMarker.SetPosition(px, py);
                if (dragMarker.OnDrag != null)
                {
                    dragMarker.OnDrag(dragMarker);
                }
                if (dragMarker is OnlineMapsMarker)
                {
                    map.Redraw();
                }
            }
            lastPositionLng = lng;
            lastPositionLat = lat;
        }
    }
Beispiel #14
0
        private void OnFindLocationComplete(string result)
        {
            Vector2 position = OnlineMapsGoogleGeocoding.GetCoordinatesFromResult(result);

            if (position == Vector2.zero)
            {
                return;
            }

            if (searchMarker == null)
            {
                searchMarker = OnlineMapsMarkerManager.CreateItem(position, search);
            }
            else
            {
                searchMarker.position = position;
                searchMarker.label    = search;
            }

            if (map.zoom < 13)
            {
                map.zoom = 13;
            }

            map.position = position;
            map.Redraw();
        }
Beispiel #15
0
        private void OnStartDownloadTile(OnlineMapsTile tile)
        {
            Texture2D tileTexture = new Texture2D(256, 256);

            // Here your code to load tile texture from any source.

            // Apply your texture in the buffer and redraws the map.
            if (map.control.resultIsTexture)
            {
                // Apply tile texture
                (tile as OnlineMapsRasterTile).ApplyTexture(tileTexture as Texture2D);

                // Send tile to buffer
                map.buffer.ApplyTile(tile);

                // Destroy the texture, because it is no longer needed.
                OnlineMapsUtils.Destroy(tileTexture);
            }
            else
            {
                // Send tile texture
                tile.texture = tileTexture;

                // Change tile status
                tile.status = OnlineMapsTileStatus.loaded;
            }

            // Redraw map (using best redraw type)
            map.Redraw();
        }
Beispiel #16
0
    public override void OnInspectorGUI()
    {
        bool dirty = false;

        OnlineMapsControlBase control = target as OnlineMapsControlBase;

        OnlineMapsControlBaseEditor.CheckMultipleInstances(control, ref dirty);

        OnlineMaps map = OnlineMapsControlBaseEditor.GetOnlineMaps(control);

        OnlineMapsControlBaseEditor.CheckTarget(map, OnlineMapsTarget.texture, ref dirty);

        DrawCurvedUIWarning();

        base.OnInspectorGUI();

        if (dirty)
        {
            EditorUtility.SetDirty(map);
            EditorUtility.SetDirty(control);
            if (!Application.isPlaying)
            {
#if UNITY_5_3P
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
#endif
            }
            else
            {
                map.Redraw();
            }
        }
    }
Beispiel #17
0
    public void OncenterClick(int id)
    {
        // PanelPopUp.intance.OnInitInforPopUp("No service");
        Vector2 position = Datacenter.instance.listCenter[id].pos;

        if (position != Vector2.zero)
        {
            if (_searchMarker == null)
            {
                _searchMarker = _api.AddMarker(position);
            }
            else
            {
                _searchMarker.position = position;
                _searchMarker.label    = "center Localtion";
            }

            _api.zoom = 15;

            _api.position = position;
            _api.Redraw();
            ChooseCenter = id;
        }
        //else
        //{
        //    PanelPopUp.intance.OnInitInforPopUp("Opps","No services!");
        //}
    }
    public override void OnInspectorGUI()
    {
        bool dirty = false;

        OnlineMapsControlBase control = target as OnlineMapsControlBase;

        OnlineMapsControlBaseEditor.CheckMultipleInstances(control, ref dirty);

        OnlineMaps map = OnlineMapsControlBaseEditor.GetOnlineMaps(control);

        OnlineMapsControlBaseEditor.CheckTarget(map, OnlineMapsTarget.texture, ref dirty);

#if !NGUI
        if (GUILayout.Button("Enable NGUI"))
        {
            if (EditorUtility.DisplayDialog("Enable NGUI", "You have NGUI in your project?", "Yes, I have NGUI", "Cancel"))
            {
                OnlineMapsEditor.AddCompilerDirective("NGUI");
            }
        }
#else
        if (noColliderWarning)
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);

            EditorGUILayout.HelpBox("Potential problem detected:\nGameObject has no BoxCollider, so you can not control the map.", MessageType.Warning);
            if (GUILayout.Button("Add BoxCollider"))
            {
                BoxCollider bc        = map.gameObject.AddComponent <BoxCollider>();
                UITexture   uiTexture = map.GetComponent <UITexture>();
                if (uiTexture != null)
                {
                    bc.size = uiTexture.localSize;
                }
            }

            EditorGUILayout.EndVertical();
        }

        base.OnInspectorGUI();
#endif

        if (dirty)
        {
            EditorUtility.SetDirty(map);
            EditorUtility.SetDirty(control);
            if (!Application.isPlaying)
            {
#if UNITY_5_3P
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
#endif
            }
            else
            {
                map.Redraw();
            }
        }
    }
    /// <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();
    }
Beispiel #20
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();
    }
        private void StartAnim(float targetZoom)
        {
            fromZoom = map.floatZoom;
            toZoom   = targetZoom;
            if (map.zoomRange != null)
            {
                toZoom = map.zoomRange.CheckAndFix(toZoom);
            }
            progress      = 0;
            inputPosition = control.GetInputPosition();
            isAnim        = true;

            lastUpdateTime = Time.time;

            map.OnMapUpdated -= UpdateZoom;
            map.OnMapUpdated += UpdateZoom;

            map.Redraw();
        }
Beispiel #22
0
    private void UpdateMarker()
    {
        if (_marker == null)
        {
            if (markerType == OnlineMapsLocationServiceMarkerType.twoD)
            {
                _marker = OnlineMaps.instance.AddMarker(position, marker2DTexture, markerTooltip);
                (_marker as OnlineMapsMarker).align = marker2DAlign;
            }
            else
            {
                OnlineMapsControlBase3D control = OnlineMapsControlBase3D.instance;
                if (control == null)
                {
                    Debug.LogError("You must use the 3D control (Texture or Tileset).");
                    createMarkerInUserPosition = false;
                    return;
                }
                _marker       = control.AddMarker3D(position, marker3DPrefab);
                _marker.label = markerTooltip;
            }
        }
        else
        {
            _marker.position = position;
        }

        if (useCompassForMarker)
        {
            if (markerType == OnlineMapsLocationServiceMarkerType.twoD)
            {
                (_marker as OnlineMapsMarker).rotation = trueHeading / 360;
            }
            else
            {
                (_marker as OnlineMapsMarker3D).rotation = Quaternion.Euler(0, trueHeading, 0);
            }
        }

        api.Redraw();
    }
    protected override void OnSetDirty()
    {
        base.OnSetDirty();

        EditorUtility.SetDirty(map);
        EditorUtility.SetDirty(control);

        if (Application.isPlaying)
        {
            map.Redraw();
        }
    }
Beispiel #24
0
    protected override void OnSetDirty()
    {
        base.OnSetDirty();

        EditorUtility.SetDirty(map);
        EditorUtility.SetDirty(control);

        if (OnlineMaps.isPlaying)
        {
            map.Redraw();
        }
    }
Beispiel #25
0
 private void Update()
 {
     if (mode == OnlineMapsRWTConnectorMode.markerOnPosition)
     {
         Vector2 newPos = currentPosition;
         if (marker.position != newPos)
         {
             marker.position = newPos;
             api.Redraw();
         }
     }
     else if (mode == OnlineMapsRWTConnectorMode.centerOnPosition)
     {
         Vector2 newPos = currentPosition;
         if (api.position != newPos)
         {
             api.position = currentPosition;
             api.Redraw();
         }
     }
 }
Beispiel #26
0
 private void Update()
 {
     if (mode == Mode.markerOnPosition)
     {
         Vector2 newPos = currentPosition;
         if (marker.position != newPos)
         {
             marker.position = newPos;
             map.Redraw();
         }
     }
     else if (mode == Mode.centerOnPosition)
     {
         Vector2 newPos = currentPosition;
         if (map.position != newPos)
         {
             map.position = currentPosition;
             map.Redraw();
         }
     }
 }
Beispiel #27
0
    protected void RedrawMap()
    {
        OnlineMaps map = (target as OnlineMapsElevationManagerBase).GetComponent <OnlineMaps>();

        if (map == null)
        {
            map = OnlineMaps.instance;
        }
        if (map != null)
        {
            map.Redraw();
        }
    }
Beispiel #28
0
        private void OnStartDownloadTile(OnlineMapsTile tile)
        {
            // Note: create a texture only when you are sure that the tile exists.
            // Otherwise, you will get a memory leak.
            Texture2D tileTexture = new Texture2D(256, 256);

            // Here your code to load tile texture from any source.


            // Note: If the tile will load asynchronously, set
            // tile.status = OnlineMapsTileStatus.loading;
            // Otherwise, the map will try to load the tile again and again.

            // Apply your texture in the buffer and redraws the map.
            if (map.control.resultIsTexture)
            {
                // Apply tile texture
                (tile as OnlineMapsRasterTile).ApplyTexture(tileTexture as Texture2D);

                // Send tile to buffer
                map.buffer.ApplyTile(tile);

                // Destroy the texture, because it is no longer needed.
                OnlineMapsUtils.Destroy(tileTexture);
            }
            else
            {
                // Send tile texture
                tile.texture = tileTexture;

                // Change tile status
                tile.status = OnlineMapsTileStatus.loaded;
            }

            // Note: If the tile does not exist or an error occurred, set
            // tile.status = OnlineMapsTileStatus.error;
            // Otherwise, the map will try to load the tile again and again.

            // Redraw map (using best redraw type)
            map.Redraw();
        }
Beispiel #29
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!";
                }
            }
        }
    }
Beispiel #30
0
    public override void OnInspectorGUI()
    {
        bool dirty = false;

        OnlineMapsControlBase control = target as OnlineMapsControlBase;

        OnlineMapsControlBaseEditor.CheckMultipleInstances(control, ref dirty);

        OnlineMaps map = OnlineMapsControlBaseEditor.GetOnlineMaps(control);

        OnlineMapsControlBaseEditor.CheckTarget(map, OnlineMapsTarget.texture, ref dirty);

#if !DFGUI
        if (GUILayout.Button("Enable DFGUI"))
        {
            if (EditorUtility.DisplayDialog("Enable DFGUI", "You have DFGUI in your project?", "Yes, I have DFGUI", "Cancel"))
            {
                OnlineMapsEditor.AddCompilerDirective("DFGUI");
            }
        }
#else
        base.OnInspectorGUI();
#endif

        if (dirty)
        {
            EditorUtility.SetDirty(map);
            EditorUtility.SetDirty(control);
            if (!Application.isPlaying)
            {
#if UNITY_5_3P
                EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
#endif
            }
            else
            {
                map.Redraw();
            }
        }
    }