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.
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.
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.
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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With