Yes, I’m back with offline maps this time! (I’ll say it right away, it’s still a work in progress and have issues)
This was one of the most requested features since the last post and I decided to give it a shot. I have some other improvements&fixes as well but let’s do it in bullet style again, it’s so much easier for me that way.
-Offline Maps; well yes the big thing is the offline maps this time. Admittedly I just did a simple basic implementation for now, as it’s a huge topic itself, didn’t had time to do a complex complete implementation. Anyway, how it works; first of all, all you need is to use “CachedDynamicLoader”. That’s all. This script has a simple caching system; every time it needs to load a tile, it first checks if it exists in a predefined folder. If it’s there, it just loads the file and reads the Mapzen data from that, if not it requests the data from Mapzen api and then saves it in that folder for later usage.
Want to test it? You should run the “CachedDynamicLoader” scene and run around a bit. In this initial run, there will be nothing cached so it’ll load everything from server BUT it’ll also save them as a file. Notice how long it takes to load single tile. Now restart the game, you can even unplug your internet connection at this point, and this time, it’ll load everything from file system, much much faster.
But be careful, there is a little unsolved (for now) issue here; it takes so little time to load data from file so it’ll try to load and create all tiles at once, which will most likely freeze the editor. I’ll look into this in the future, for now try to stick with range 1 or something small like that. So yea, it’s far from done for now but it’ll only get better. It’s on this update so that you can work on it as you want as well.
-Next… well there is Road settings things I did today. If you check the road factory, you’ll see the settings property is quite extended now. It has an array of RoadSettings, where you can choose the road type (path, minor road, major road etc), road width and material.With this, it’ll be so much easier to change any settings in game. It’ll also easy to extend settings for more road types and options as well. I’ll try this for a while and if it works out well, I’ll do the same for other factories as well!
-Then we have real building heights. I honestly thought I did this long ago but… well turns out I didn’t. It’s a small thing really, building factory now checks if the building has height property set, if it does uses that, if not takes a random number. That’s all.
-Also fixed some issues from Github page here. I’m also posting there on daily basis so please, don’t be shy to open new issues for bugs or feature requests. It’s much easier to discuss things there and I have 16 closed issues so… yeay!!!!
Yep, that’s all for this update I guess. Please do let me know what you think. I’m trying to build my road plan according to feedbacks, feature requests and bug reports.
18 thoughts on “PokemonGo clone using Mapzen – Part 6: Offline Maps”
hi brnkhy, im trying to test this new version,and i have some problems.im using unity 5.0.0.first, i need to change protected string _key to public string _key…..after that i dont see errors in console, but when i play, y have this error:
maybe you know how can i fix it???or what im doing wrong??….thanks…
That was a silly mistake by me, can you please replace this line in building factory;
GetVertices(tileMercPos, _settings.AllSettings, items, verts, indices);
GetVertices(tileMercPos, _settings.Default, items, verts, indices);
I’ll try to post fixed package asap, thanks mate
thanks brnkhy…..now run fine…..i will go to test it….;-)
Great! Let me know if you have any other issues 😉
Thanks for this series. I’ve been playing around with both Google Maps and MapBox. I had never heard of MapZen before your series. I’m going to work on it as another option to play around with as I’m working on my prototype. I haven’t dug into everything available with the other two, but this is the first tutorial I’ve seen on any of them that deals with determining things like borders. I really wanted to figure out something to mark off public parks and water to be colored differently. I’m pretty sure you can do with the others too, I just don’t know how yet.
At any rate, I look forward to seeing more of what you can do with MapZen. I would love to see something on how to get MapZen to pull up info similar to Google Places. Back in one of the tutorials you identified parks via land use. Is it possible to pull up and cache lists of historical sites? Other location types? I’m wanting to do something similar to PokeStops where they seemed to be tied to community centers, parks, historical places, etc. Is this possible with MapZen? Would be great to be able to cache like you are doing the maps and when a new tile is loaded have it check both for offline maps as well as an existing locations list. Maybe have some type of counter that will only check the API for updates daily, weekly, etc to lower api calls?
Great job so far! Keep up the awesome work!
I don’t know much about Mapbox but from what I’ve seen, it’s so much easier for simpler/smaller projects. As you noted, I love the flexibility and potential of Mapzen, there is sooo mcuh to play with. I’m not sure if Mapbox provides that.
I already did a simple “Custom Object” handler (should be on dev branch on git), which let’s you save specific locations (in lat/long) and it’ll visualize those points in app (with a simple sphere for now). It’s also certainly possible to do it for parks or any place Mapzen categorized. There is also a POI (points of interest) layer but I haven’t had time to look into it yet. There is sooo much to do and I have so little time these days (with two huge project deadlines coming…)
Thanks a lot man! I’m doing my best, working on this project in all my free time 🙂
hi brnkhy,after play with it, i found two little things…..the buildings dont start in the same plane as street,is a hole between buildings and street…….and the other thing is a few buildings are missing….in my city…..maybe are not easy shapes?….the rest i test..its ok….ah….im waiting for the gps stuff…;-), i hope you can do it soon….thanks for this great project…..
The empty space between roads and buildings is probably because of the road width setting. As far as I can see, default setting is quite small and yea doesn’t fill that space at all.
About missing buildings; they are either not mapped in Mapzen OR there is a known issue with triangulation code which flip’s the roof for certain buildings. Can you check from scene view if you can see those buildings from below?
I’m hoping to do the GPS thing soon as well, cheers! 🙂
hi brnkhy, im looking, but no….the building its lost….but in version 5 , the building exist, you can see it in this pic.
but i see you are update a new version….im going to look if the error exist in this one.thanks….and sorry for my bad english..;-)
Interesting… Can you give me the lat/long so I can check what’s going on? (You can mail it as well) No idea what might be wrong with that.
yes..in the pic you can see lat and long…..;-)
hahaha no idea how I missed that >< I'l check it as soon as possible man, thanks again.
Wait I just checked it, http://imgur.com/gallery/hLxoM
It’s there in the latest version 😉
Hi BRNKHY, thanks a lot for amazing tutorial
btw, I’m trying to use GPS for player movement. can you help me how to do ?
Hey Tomoki, glad you like it!
I’m still working on map details&layers, I’ll move to other stuff like gps&android once I’m satisfied with map but it’s not there yet 🙂
Thanks for reply^^
cant wait for your update
keep it up
btw, It this possible to add some object in the map with given coordinates (longitude and latitude) ?
Yeap, check the CustomObject plugin class 😉