Пример #1
0
    APICalls()
    {
        Debug.Log("API Calls being made");
        osmMapData = await Task.Run(() => api.GetOsmMap());   //working

        mapBounds = await Task.Run(() => api.GetMapBounds()); //working

        Debug.Log("Datapoint getting");
        dataPointId = await Task.Run(() => api.GetPointLocations());

        models = await Task.Run(() => api.GetModels());

        try
        {
            histMapContainer = api.GetHistMap();
            historyMapData   = histMapContainer.MapData;
            historyMap       = gWorld.LoadDataIntoTexture(historyMapData);
        }
        catch (Exception e)
        {
            Debug.Log("Historical map not found: " + e);
            // This means there was no historical map in the db
        }
        goForApi = true;
    }
Пример #2
0
    /// <summary>
    /// Loads OSM map from api and displays it on plane
    /// </summary>
    private void LoadOSMMap()
    {
        // Get the osm data and create a texture out of it
        var       osmMapData = api.GetOsmMap();
        Texture2D mapTexture = new Texture2D(2, 2);

        mapTexture.LoadImage(osmMapData);

        // Scale the plane appropriately
        float scaleX = mapTexture.width / 400f;
        float scaleZ = mapTexture.height / 400f;

        MapPlane.transform.localScale = new Vector3(scaleX, 1, scaleZ);

        // Wrap the texture in a Material and apply it to the plane
        Material material = new Material(Shader.Find("Standard"));

        material.renderQueue = 2998; //to fix the clipping issue
        material.mainTexture = mapTexture;
        MapPlane.GetComponent <Renderer>().material = material;

        // Fix the upsidedown PNG...
        MapPlane.GetComponent <Renderer>().material.SetTextureScale("_MainTex", new Vector2(-1, -1));
    }