Mapi - Simple mapping API

edited in Projects
Hi I'm busy building a mapping API and I'm posting here for developers that might be interested in integrating maps into their project. For more info you can check out the Wiki.

Features
  • navigate map using mouse
  • place, move & delete markers
  • return routing data between two points
  • create custom markers
  • dynamic icon loading
  • get detailed routing info and highlight routes on the map
  • interact directly with the Open Street Map data
Demos

Comments

  • I know @Raxter was working with a mapping API for one of his prototypes... I'm wondering if this is something that you're doing for some external reason (like school or coursework) or if it's something that you feel you need to do before you can finish a game?

    If it's the latter I'd urge you to poke @Raxter and find out what he's been using to save you some effort ;)
  • It looks like you only have the minified version of the JavaScript in your source control? Any chance you're going to put the original source up?
  • edited
    indeed, I'm working on a prototype of a (well any) game that involved OpenStreetMap data (now with geographic altitude maps!) to make realistic (literally, real) maps on which massive global warfare might occur. Image is attached for example (I don't know how to put it in place)

    What I'm doing I'd use the SVG [edit: I meant XML, not SVG] data available from OpenStreetMap. I'm planning on making it stream the data from a server (right now I read off files I've downloaded onto disk)

    but that is quite a far way away (I should be finishing my masters thesis as is :p) unfortunately I don't have much else to add, all that streaming off a server stuff will come after I'm more certain I have a decent game out of all of this!
    scenic_view_of_the_landscape.png
    1920 x 1080 - 721K
  • @dislekcia - It's work related, I also wanted a mapping API that is more suited to be used for game development.

    @aodendaal - I will be releasing a the original source later this week. Are you interested in using this API in a project?

    @raxter - I think your project is really cool, it would be very useful for developers if they could generate realistic terrain using OSM data. If you just want to download data for a specific area you can check out this link http://downloads.cloudmade.com/africa/southern_africa/south_africa#downloads_breadcrumbs. The current problem I'm having is to select an entire road, can you help me with this?
  • So far I just downloaded the OSM xml file for cape town that I selected and extracted from the OSM site. As far as I understand, roads are grouped into 'ways', which is a collection of 'nodes' (where a node is a single geographical point). 'Ways' have a number of optional tags attached to them, one of which is the 'name' tag and the 'highway', if the 'highway' tag is defined then 'name' tag (if defined) should be the name of the road.

    But this is with the really detailed xml file, are you extracting the xml data or just the images from OSM? Or some other method I have not realised exists? I would like to dig around your code to check myself but I don't speak JavaScript very well so it'd take too much time right now for me to figure all it out by myself (trying to finish up a thesis by the end of the month :-/ hope you understand that time is a bit tight for me atm).

    Willing to help out if I can (time-depending!), I'm only just getting my head into the whole OSM stuff myself! :-P

    p.s:
    The height data I get from an external source, http://srtm.csi.cgiar.org/index.asp but this might have legal issues for public distribution and also no streaming web API like OSM or OpenLayers. The pic in my last post is at 90m resolution, I'm trying to get my hands on the 30m data that is also (I think) legal-issue free.
  • Wow @raxter, I really like how that terrain looks with the roads on it. Are you going to keep the game all minimalist? I think that would be amazing...
  • @raxter - I'm also getting my data from OSM XML files and accessing the data via http://postgis.refractions.net/. I'm also looking at the PBF format which is a binary version of the XML data, check http://wiki.openstreetmap.org/wiki/PBF . Are you drawing the lines at runtime, what sort of performance are you getting? You can use the data to generate road textures which will give you a speed boost, but you might need an external tool, or maybe Unity has the ability to be extended to allow this.
  • @dislekcia Many thanks ^_^ yeah I tried to add textures to the terrain, but combination of my inexperience in art design and the fact that it just looked crap no matter what I did means that I think I'll keep it minimal for now :p might make the roads a red or green wire-frame and go all battlezone up in it, or at least some form of semi-digital looking warfare. It's still a tech-test at the moment so once I have some gameplay mechanic attached to it I'll think of art design (though minimal seems the way to go due to the overwhelming number of roads and connections).

    @reflex that PBF format looks like it'll be important for later editions, thanks! Currently I am scanning through the file using the c# xml parser and reading them into memory in my own format (hashmaps errywhere for fast lookups). I then create a a LineRenderer for each 'way' that is a 'highway'. Parsing and loading the whole file and creating the LineRenderers takes about 5 seconds in total (also including the time it takes to parse the heightmap file). There are about 5000 ways/LineRenderers and it runs like a badass on my i7 950 + GTX 295.

    I'd be interested to start pushing the boundaries in various places. One thing I can see is that I'll probably need to combine multiple 'ways' into one to reduce the number of LineRenderers I'm creating. Also might have to have some form of level of detail scheme, 'cause up close LineRenderers don't look very road-like, but if I created geometry for all the roads the program will almost certainly start grinding. I also want to set up a streaming system whereby it'll load up data as I need it (first from files on disk, then from the interwebs or a server). But timetimeworkworkwillseewhenIcangetitdonesadface
    reflex said:
    You can use the data to generate road textures
    Not sure I understand you? Do you mean that for each type of road I can use a different texture? At the moment I'm using one texture for all of them, so I don't think one can beat that! It is simply grey with a dashed white line in the middle :p but I'm having texture-scaling problems since each road segment is a different length but the texture is fixed in unity. Leading to longer roads having great big white dashes and short roads with lots of little dotted dashes :P again, some time and clever tricks will be needed
  • @raxter - I mean generate a texture that you map to the entire terrain and create a custom shader. If you want to map the road texture correctly when you render the lines you can split up the road into segements and repeat the texture.
  • edited
    Also go have a look at DEM Explorer http://ws.csiss.gmu.edu/DEMExplorer/ ... powered by Geobrain http://geobrain.laits.gmu.edu/
  • I've made progress. I'm extracting osm data directly from openstreetmaps using their api, I then create objects to better manage the data, I can then allow the user to click on a road using some maths.
  • do you have a working example on a website?
  • @raxter - currently its on my local development pc
  • Ok I've got a screenshot.
    mapi_road_sel_01.png
    460 x 335 - 37K
  • I uploaded version 0.1 to my site for those that want to see it in action:

    http://www.namibcoder.org/mapi/

    Just note that it might take some time to load the first time...
  • edited
    Thanks @fyrewolfe

    I'm integrating the OSM API into Mapi so you can get and manipulate raw map data with ease. I'm also starting to work on the interface, I'm thinking of allowing the interface to be manipulated in an external file like I'm doing with the marker icons. I'm planning on releasing version 0.2 over the weekend and update the wiki with the new features, so keep an eye open for that.

    At the moment I'm using YOURS to get the routing data. An alternative to this is to calculate the route client side by getting the OSM data in an area around two points and using the Dijkstra's algorithm. This would remove the dependency on YOURS and avoid problems when their server is offline, like it was a week back, but it's not a priority at this point.
  • edited
    I've uploaded the latest version to demo the road selection feature. It also shows a work in progress interface that will feature in v0.2. I'm also planning on moving the wiki off bitbucket on onto my own site.

    Mapi v0.15 Demo
  • @reflex Dijkstra's algorithm looks very interesting, why not use A*?

    I would love to see the cost being more than just the distance. E.g. is a tarred road faster than a dirt road. Is road D safer than road E. etc...

    How about caching the results from the algorithm? This should allow for faster feedback on the site when determining the route from A to B without having to do the calculation for each and every client all over again.
  • Spoke to @reflex over gtalk, definitely agree on the A* since Dijkstra's is a complete search (and would end up visiting each node in the map/world). A modified/weighted A* would be sweet, indeed! I've already done an A* for my game, but I still have to fix some bugs whereby some of the roads sometimes don't connect to the rest of the roads (or at least, I think that is the case, haven't had time to work on it since my last post)
  • I've moved the Mapi Wiki to my own site and I have updated it, feel free to have a look and make suggestions for new features :)
Sign In or Register to comment.