Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Openstreetmap: embedding map in webpage (like Google Maps)

Is there a way to embed/mashup the OpenStreetMap in your page (like the way Google Maps API works)?

I need to show a map inside my page with some markers and allow dragging/zooming around, maybe routing. I suspect there would be some Javascript API for this, but I can't seem to find it.

Searching gets me an API for access to raw map data, but that seems to be more for map editing; besides, working with that would be a heavy task for AJAX.

like image 752
Piskvor left the building Avatar asked May 29 '09 09:05

Piskvor left the building


People also ask

Can I embed a Google Map in my website?

You can embed Google Maps directions, maps, or street view into a personal website. To embed Google Maps, you can navigate to the Menu tab for the HTML code of the specific directions or map view you've entered.

What is the difference between Google Maps and OpenStreetMap?

The main difference between these two services is that every edit you make to OSM is owned by you and the community, while every change you make to Google Maps… will be owned by Google. The OSM community is what makes the project so special.

Is OpenStreetMap better than Google?

OSM gives better performance in various urban centres as compared to Google Maps. Google Maps are the best for online purposes. OpenStreetMap allows the users to download the maps that can be used offline also for either finding a route or identifying a location.


2 Answers

You need to use some JavaScript stuff to show your map. OpenLayers is the number one choice for this.

There is an example at http://wiki.openstreetmap.org/wiki/OpenLayers_Simple_Example and something more advanced at

http://wiki.openstreetmap.org/wiki/OpenLayers_Marker

and

http://wiki.openstreetmap.org/wiki/Openlayers_POI_layer_example

like image 168
lhahne Avatar answered Sep 19 '22 17:09

lhahne


There's now also Leaflet, which is built with mobile devices in mind.

There is a Quick Start Guide for leaflet. Besides basic features such as markers, with plugins it also supports routing using an external service.

For a simple map, it is IMHO easier and faster to set up than OpenLayers, yet fully configurable and tweakable for more complex uses.

like image 33
2 revs, 2 users 71% Avatar answered Sep 21 '22 17:09

2 revs, 2 users 71%