Giter Club home page Giter Club logo

osmbuildings's Introduction

OSM Buildings

A JavaScript library for visualizing 3D OSM building data on interactive maps

Important

The whole library consists of client JavaScript files, a server side PHP script and a MySQL database. Everything should be handled as alpha state. All components are likely to change extensively.

Bottleneck is data availability. I can't process and host a whole OSM planet file. Actually I'm looking for a partner to provide a data service to you.

Prerequisites

  1. You will need MySQL as data storage. Version 5.0.16 or better has the required Spatial Extensions enabled. Everything can be done in different Geo enabled databases too. For now we just go MySQL.

  2. You will need to import OSM building data from /server/buildings.sql.zip. Either upload this directly in PhpMyAdmin or unpack and import as you like.

  3. Make sure PHP is running and create a /server/config.php file for your MySQL credentials. Or just adapt and rename /server/config.sample.php for your needs.

Integration

I assume, Leaflet is already integrated in your html page. If not, head over to its documentation.

Then in header section, add:

<head>
    :
    :
  <script src="dist/buildings.js"></script>
</head>

after Leaflet initialization add:

var map = new L.Map('map');
  :
  :
// you may stay with any maptiles you are already using. these are just my favourites.
// remember to obtain an API key from <a href="http://mapbox.com">MapBox</a>.
// please keep the attribution part for proper copyright notice.
var mapboxTiles = new L.TileLayer(
	"http://{s}.tiles.mapbox.com/v3/mapbox.mapbox-streets/{z}/{x}/{y}.png",
	{
		attribution: 'Buildings engine &copy; <a href="http://flyjs.com">FlyJS</a> &bull; Map data &copy; 2012 <a href="http://openstreetmap.org">OpenStreetMap</a> contributors <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA  2.0</a> &bull; Map tiles &copy; <a href="http://mapbox.com">MapBox</a>',
		maxZoom: 17
	}
);

// there is just data for Berlin, Germany at the moment, lets start there
map.setView(new L.LatLng(52.52111, 13.40988), 17).addLayer(mapboxTiles);

// this applies the functionality to Leaflet
Buildings.setMap("leaflet", map);

// this finally starts loading data from your PHP/MySQL combo
// you will need to have this on the same server, otherwise there are cross origin issues
Buildings.load("server/?w={w}&n={n}&e={e}&s={s}&z={z}", {
	strokeRoofs: false,
	wallColor: "rgb(190,170,150)",
	roofColor: "rgb(230,220,210)",
	strokeColor: "rgb(145,140,135)"
});

done.

For any further information visit http://flyjs.com/buildings, follow @osmbuildings on Twitter or report issues here on Github.

osmbuildings's People

Stargazers

 avatar

Watchers

 avatar

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.