Giter Site home page Giter Site logo

unityslippymap's Introduction

UnitySlippyMap

A slippy map implementation written in C# for Unity3D.

It aims at helping developpers create 2D/3D maps working with a variety of online tile providers (OpenStreetMap, VirtualEarth/Bing Maps, ...) and offline sources (DBMap, MBTiles, ...) like Route-me (iOS) or Leaflet (HTML5), on every platform supported by Unity3D. Google Maps won't be supported (see Google Maps tiles terms of service). Yahoo! Maps neither since it was closed on September 13, 2011. Nokia Maps (now called Here) provides a REST API designed for static maps. They could be used as tiles but would get a 'Nokia' watermark on each one of them. Also Nokia and Microsoft are now teaming up so supporting both might be redundant.

Hopefully, it will also be compliant with a number of popular OGC standards like WMS or GML.

Map objects (tiles, markers, ...) are placed in 3D space along X and Z axis. The idea is to be able to use 3D geometry as terrain or markers with a free camera.

Current status

UnitySlippyMap is in alpha stage and currently supports:

See the TODO list if you want to contribute and don't know where to start.

License

UnitySplippyMap is released under the MIT License.

Unity Version

UnitySplippyMap requires at least Unity 2021.3.26f1

TODO

Here is a short list of what could be fixed or added to UnitySlippyMap:

  • Fix the voodooish way I implemented the camera elevation and tile positioning (see the comments in Map.cs)

  • Handle device orientations properly when using the compass

  • Add new map objects (polygons, lines, ...)

  • Add support for orthographic cameras

  • Add a better zoom rounding (>80%, <20%?)

  • Add a map constraint to a given 'size', bounce on limits

  • Add movements inertia

  • Support other versions of WMS (used trang to convert dtd to xsd, then Xsd2Code to generate xml serializable classes)

  • Subdomain rotations for VirtualEarth & OSM

  • Display logo and copyright for VirtualEarth (url in metadata) & OSM (see OSM Wiki)

  • Optimise, use one material for the tiles to enable dynamic batching: tried and failed, merging textures on the fly is to costly (see TextureAtlasManager.cs)

unityslippymap's People

Contributors

astrubel avatar colivienter avatar jondewoo avatar pinglis avatar pixelfat avatar tamleis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unityslippymap's Issues

Can't see markers on the map

I'm sorry for a newbie question here, I think I couldn't find a way to generate markers on the map.

I can see that this line should work: map.CreateMarker<MarkerBehaviour>("test marker - 9 rue Gentil, Lyon", new double[2] { 4.83527, 45.76487 }, markerGO); but i don't see any markers on the map.

Also I'm getting the error:

DllNotFoundException: sqlite3
SqliteDatabase.Open (System.String path) (at Assets/UnitySlippyMap/Helpers/SQLite/SqliteDatabase.cs:91)
UnitySlippyMap.Layers.MBTilesLayerBehaviour.Open () (at Assets/UnitySlippyMap/Layers/MBTilesLayerBehaviour.cs:173)
UnitySlippyMap.Layers.MBTilesLayerBehaviour.set_Filepath (System.String value) (at Assets/UnitySlippyMap/Layers/MBTilesLayerBehaviour.cs:53)
TestMap+c__Iterator0.MoveNext () (at Assets/TestScripts/TestMap.cs:273)

maybe those are related?

MaxZoom

Can the map be zoomed more (like Google Maps)? Awesome project by the way, works great!

Problem working on Android (Unity 4.6.3)

Hello, I'm working on Unity 4.6.3, on an Android application.

The map work fine in Unity (in editor), but not in Android.
By not working I mean that I can see the buttons but I don't see any map tiles.
The DebugLogs are telling me that everything is working :

(TestMap.cs )

Debug.Log("DEBUG: file doesn't exist: " + newfilepath);
Debug.Log("DEBUG: will write: '" + filepath + "' to: '" + newfilepath + "'");
Debug.Log("DEBUG: exists: " + newfilepath);
Debug.Log("DEBUG: using MBTiles file: " + filepath);

All these messages are showing, so it should work correctly but nothing is showing on Android.

So if you know what the problem can be, please let me know =).

And thanks in advance for your answers.

Click on markers

Hello.

Is ther a way to click or touch in markers? I would like to add a listener to the markers to open a screen with the information of a place. But i don't know how do this. I add a listener, but it never get the action.

`GameObject markerGO = Instantiate(go) as GameObject;
map.CreateMarker("Point", map.CenterWGS84, markerGO);
MapInput.lat = map.CenterWGS84[0];
MapInput.lon = map.CenterWGS84[1];
double[] point = new double[2];
point[0] = map.CenterWGS84[0];
point[1] = map.CenterWGS84[1];
MapInput.sitios.Add(point);

markerGO.GetComponent().material.mainTexture = Resources.Load("green_marker") as Texture;
markerGO.GetComponent().material.color = new Color(1.0f, 1.0f, 1.0f, 1.0f);

markerGO.AddComponent().onClick.AddListener(() => OnClick());`

Thank you.

Problems with GPS on and coordenates

In Android devices, with diferent versions of Android and smaller than 7.0, if the GPS is on, UnitySlippyMap gets the coordenates well. But when starts to show the map tiles in the screen, the app stops and breaks.
Instead, if the GPS is off, the app use prefered coordinates and the map works well.

With Android 7.0, in a Huawei P9 Lite device, the app also breaks if the GPS is on and if the GPS is off, the coordinates show a diferent place. The latitude is longitude and the longitude is latitude. I don't know if this is an Android 7.0 problem or the device problem.

I'm using Unity3d 5.1.1f1

Thank you.

Location Marker Not showing

I can't figure out why the location marker is not showing up. Any help would be much appreciated. Thanks.

using UnityEngine;
using UnitySlippyMap.Map;
using UnitySlippyMap.Layers;
using UnitySlippyMap.Markers;
using System.IO;
using System.Collections;
using System.Collections.Generic;

public class TileMap : MonoBehaviour {

private MapBehaviour map;
public Texture MarkerTexture;
public Texture LocationTexture;
private List<LayerBehaviour> layers;


// Use this for initialization
void Start () {

    // create the map singleton
    map = MapBehaviour.Instance;
    map.CurrentCamera = Camera.main;
    map.InputDelegate += UnitySlippyMap.Input.MapInput.BasicTouchAndKeyboard;
    map.CurrentZoom = 16.0f;
    //map.UpdatesCenterWithLocation = true;  NOT WORKING

    // Location
    map.CenterWGS84 = new double[2] { 73.080740, 33.597513 };
    map.UsesLocation = true;
    map.InputsEnabled = true;
    layers = new List<LayerBehaviour>();

    // create an OSM tile layer
    OSMTileLayer osmLayer = map.CreateLayer<OSMTileLayer>("OSM");
    osmLayer.BaseURL = "http://a.tile.openstreetmap.org/";

    layers.Add(osmLayer);

   
    // create some test 2D markers
    GameObject go = TileBehaviour.CreateTileTemplate(TileBehaviour.AnchorPoint.BottomCenter).gameObject;
    go.GetComponent<Renderer>().material.mainTexture = MarkerTexture;
    go.GetComponent<Renderer>().material.renderQueue = 4001;
    go.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
    go.transform.localScale /= 7.0f;
    go.AddComponent<CameraFacingBillboard>().Axis = Vector3.up;

    GameObject markerGO;
    markerGO = Instantiate(go) as GameObject;
    map.CreateMarker<MarkerBehaviour>("test marker 1", new double[2] { 73.080740, 33.597513 }, markerGO);

    markerGO = Instantiate(go) as GameObject;
    map.CreateMarker<MarkerBehaviour>("test marker 2", new double[2] { 73.080860, 33.597933 }, markerGO);

    markerGO = Instantiate(go) as GameObject;
    map.CreateMarker<MarkerBehaviour>("test marker 3", new double[2] { 73.080220, 33.597899 }, markerGO);

    DestroyImmediate(go);

    // create the location marker
    go = TileBehaviour.CreateTileTemplate().gameObject;
    go.GetComponent<Renderer>().material.mainTexture = LocationTexture;
    go.GetComponent<Renderer>().material.renderQueue = 4000;
    go.transform.localScale /= 27.0f;

    markerGO = Instantiate(go) as GameObject;
    map.SetLocationMarker<LocationMarkerBehaviour>(markerGO);

    DestroyImmediate(go);
}

void OnApplicationQuit()
{
    map = null;
}

// Update is called once per frame
void Update () {

}

}

image

Offline/Lock to Specifc Area

I was wondering if it was possible to use this SDK in an offline app (i.e. download the necessary tiles before building the package?)

Also is there any way to lock the area to be viewed to a considerably smaller area (i.e. defined by maximum and minimum coordinates?)

MBTiles stack overflow error / Problem with adding this implementation to newer Unity versions

Hello, first of all: Thank you @jderrough and everyone else who contributed for this project! I had trouble getting an offline map to work on the HoloLens, but this project solved it for me. Though I do not like the way it handles the zoom based on camera distance/frustum, but thanks to a different issue here I was able to still make it work with my project by using a seperate camera render texture.

Anyway, When I tried to implement the project (Only using MBtiles and no online layers) in my existing project (using Unity 2019.4.18f1) the editor took a very long time after hitting play until finally it started with a stack overflow error and no visible tiles. After 2 days of researching I found out that the problem was in the Physics settings. The "Auto Sync Transforms" checkbox has to be checked. Apparently it was checked in older Unity versions by default, but it is not checked anymore in newer Unity versions.

I still have no idea why it causes this problem, but I hope by writing this I can help someone in the future. And I also hope that the problem was not caused by any changes I made to this implementation, otherwise this issue would be invalid

Map on plane

Hi,

im pretty new to unity and asking myself if it may be possible to render the map to a simple plane instead of the camera? What i try to achieve basically is:

Rendering the map to a plane, my "game world" so to speak. There were many libraries on the internet, which can render a map with openstreetmaps, but I don't want it to be a real 3D map but a 2D map instead. The problem is, with the camera rendering the map i can't zoom and place 3D objects, like a player model on it.

Any help would be appreciated, just some tips may be enough, as I'm already looking to find the solution, but if it's definitely impossible I wouldn't waste that much time on it and instead search for another solution.

Regards,

Flo

Can't input coordinates above longtitude 100.

If i input a long above 90, i will get the following warning:
ArgumentException: Transformation cannot be computed at the poles.
at Map.CenterWGS84: double[] newCenterESPG900913 = wgs84ToEPSG900913Transform.Transform (value);
If i try to enter something like singapore (long at 103 or something like that), as the starting center. The code will simply freeze unity.

Any reason for this issue and any idea how to fix it?

Marks not appearing

Hi team,
Is anyone else having issues with the markers not appearing? I see there is a todo for the marker layer, but was wondering if the current version works as expected.

Thank you.

Kelvin

How to enable caching?

The plugin keeps the tiles visible on the screen in cache and no other which makes the navigation experience quite slow. Is there a way to enable caching for the OSM map in the plugin?

2 Errors in Demo with Unity2018

There are 2 errors in your demo with Unity2018:

Assets/UnitySlippyMap/Helpers/TextureBogusExtension.cs(39,25): error CS1540: Cannot access protected member UnityEngine.Texture.Texture()' via a qualifier of type UnityEngine.Texture'. The qualifier must be of type TextureBogusExtension' or derived from it`

Assets/UnitySlippyMap/Helpers/TextureBogusExtension.cs(39,25): error CS0122: UnityEngine.Texture.Texture()' is inaccessible due to its protection level`

How to fix it?

Streaming WMS data

The URL used for the WMS tiles seems to no longer be accessible or the 1.1.1 version is no more usable:

ERROR: WMSTileLayer.Update: loader [http://labs.metacarta.com/wms/vmap0?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.1.1] error: couldn't connect to host()

Crash on IOS 13

Hey ,
Getting a crash on iPhone 11,Attaching the log,
Thanks for the project. It is really an awesome tool to display Maps.

-[NSURLResponse statusCode]: unrecognized selector sent to instance 0x282e60700
2020-01-11 13:00:51.015005+0530 sabg2[423:30874] Uncaught exception: NSInvalidArgumentException: -[NSURLResponse statusCode]: unrecognized selector sent to instance 0x282e60700
(
0 CoreFoundation 0x00000001b6549560 2A356815-C9F4-3364-9AAC-B56FC2A4DD20 + 1254752
1 libobjc.A.dylib 0x00000001b62640c8 objc_exception_throw + 60
2 CoreFoundation 0x00000001b6447b60 2A356815-C9F4-3364-9AAC-B56FC2A4DD20 + 199520
3 CoreFoundation 0x00000001b654dbd4 2A356815-C9F4-3364-9AAC-B56FC2A4DD20 + 1272788
4 CoreFoundation 0x00000001b654fac0 _CF_forwarding_prep_0 + 96
5 sabg2 0x0000000102f8bfa8 -[UnityWebRequestDelegate handleResponse:] + 124
6 sabg2 0x0000000102f8bee0 -[UnityWebRequestDelegate URLSession:dataTask:didReceiveResponse:completionHandler:] + 68
7 CFNetwork 0x00000001b991e3fc _CFNetworkHTTPConnectionCacheSetLimit + 194852
8 Foundation 0x00000001b691846c 027A1168-54B3-30BA-82E5-640520D2E2CB + 1168492
9 Foundation 0x00000001b681a2a8 027A1168-54B3-30BA-82E5-640520D2E2CB + 127656
10 Foundation 0x00000001b691a7c8 027A1168-54B3-30BA-82E5-640520D2E2CB + 1177544
11 Foundation 0x00000001b6819f24 027A1168-54B3-30BA-82E5-640520D2E2CB + 126756
12 Foundation 0x00000001b691b1f4 027A1168-54B3-30BA-82E5-640520D2E2CB + 1180148
13 Foundation 0x00000001b691acb4 027A1168-54B3-30BA-82E5-640520D2E2CB + 1178804
14 libdispatch.dylib 0x00000001b61fd428 1266FC1D-1C06-3A03-9DD9-11A3C5C1C3BB + 62504
15 libdispatch.dylib 0x00000001b61f1088 1266FC1D-1C06-3A03-9DD9-11A3C5C1C3BB + 12424
16 libdispatch.dylib 0x00000001b61f3808 1266FC1D-1C06-3A03-9DD9-11A3C5C1C3BB + 22536
17 libdispatch.dylib 0x00000001b61f2f68 1266FC1D-1C06-3A03-9DD9-11A3C5C1C3BB + 20328
18 libdispatch.dylib 0x00000001b61ffc50 1266FC1D-1C06-3A03-9DD9-11A3C5C1C3BB + 72784
19 libdispatch.dylib 0x00000001b6200400 1266FC1D-1C06-3A03-9DD9-11A3C5C1C3BB + 74752
20 libsystem_pthread.dylib 0x00000001b6256a64 _pthread_wqthread + 216
21 libsystem_pthread.dylib 0x00000001b625cc7c start_wqthread + 8
)
(lldb)

OSM zoom issue

Hello,

I have encountered some issues when usig OSM map tiles. If I zoom out farther than 6 on the map, all the tiles are just grey. The material seems to have no texture loaded.

Do you have any idea what could be the reason for this or how I could get it to work for lower zoom levels?

Proper getting started guide

The project should have a getting started guide. It is currently confusing for new users how exactly a map can be added to a project. See: #29 for refactoring the example code

License requires unity projects to be LGPL if published to anywhere other than on PC

Doing some research on LGPL I have found that any unity projects that bundles the plugin into a singular program, like projects build for console, web and/or mobile would force those projects to be LGPL as well since it is not possible to supply an alternative version of the compiled library by the user.

(I'm assuming that it is not intended to restrict those platforms, that's why I opened an issue about this)

[1]http://answers.unity3d.com/questions/367198/using-a-plugin-library-having-lgpl-license.html
[2]http://forum.unity3d.com/threads/legal-question-unity3d-webgames-and-gpl-code.37692/#post-1096098

Ways to calculate zoom?

Are there any tools provided I can calculate the zoom (which would be based on how many real meters I would like to see on the screen)?

Refactor TestMap

The example/test code in TestMap.cs is quite frankly horrible to read. It should be refactored to be readable & easily understood, even for new users.

Question - Create circular area around markers

I am developing a mobile app with Unity that displays a map with several markers.
I am trying to create a circular area around the markers in the map just like the image below:

image

I started by creating a material attached to the markers that would increase and decrease depending on the Zoom level, but it doesn't work so well and I don't really think that's the best solution here.

Anyone knows how to do this with UnitySlippyMap's code?

Thank you.

cacheSize is incorrectly calculated

Delete contents of your cache directory
(on Mac ~/Library/Caches/unity.reallyreallyreal.SlippyMap)

While running check how much disk space the map is using:
watch -n 1 du -hs ~/Library/Caches/unity.reallyreallyreal.SlippyMap

The disk will go up to the limit correctly, but then it will start shrinking, it seems like the cacheSize is not keeping track of what's actually on disk, only pending loads.

If you don't have the 'watch' command install darwin ports, then 'sudo port install watch', or just du manually every now and then.

http://www.macports.org/

Help UnitySlippyMap

Hi Jonathan, when i load the app with UnitySlippyMap works fine the first time lauched, but then, i load another scene, and then load back again the UnitySlippyMap, and this error appear, (MissingReferenceException: The object of type 'TileBehaviour' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.)

How can i fax that please?

Hey members of this repo please help me out.

I am currently working on a project for a competition. I'll just brief through the project: I need to display a globe in AR with any WMS URL given by the user in realtime. He needs to have options to put URL and using get capabilities to get the layers and select the layer which he needs. I have been stuck for the past 3 months finding a solution for this. Either I get everything right AR or everything right in wms part. I have just a basic knowledge of WMS. I tried this asset WMS part works effortlessly but inorder to overlay on a globe I need to get it in a single layer or tile. When I run this the WMS layer gets separated into many tiles, which I don't need. If possible can anyone say how to get the WMS tiles in a single layer in realtime? And also I need to add a base layer to the globe which is currently not possible with this asset. I need to base layer from different WMS URL. But currently, this application supports different layers from same URL. If you find anything please help me out, I am running out of time.
Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.