Gerard Lolkema already found a tutorial to do this. The tutorial: Rails, Geocoding, and Google Maps from Andre on Tech. This tutorial provides you of a lot of code that is direct usable but because we make a dutch website we need to display addresses from The Netherlands. This functionality is not in the code (and probably not in the plugin) of Andre on Tech. He is using a web service from an other website to get the longitude and latitude from an address, but the problem is that it is only possible to send US addresses. To find that problem took us half a day.
Finally we found an alternative to put Google Maps in our website. And this is how we did it.
Put Google Maps in your webpage
First you need a Google Maps API Key
After you have your API key you need to load it like in every case you use Google Maps
after that we make a div and in that div we make a function that loads the Map from Google Maps.
The function load() will be executed when the div is loaded in html. So that means when the page is loaded the load() function will start.
The load() function looks like this:
And now we go to the addAddressToMap function again between a <script></script>. You can also put it in the same script tag as the load() function:
Of course this is not really a dynamic way but this is easy to rebuild to a more dynamic script
If you now test the script you see the script is working and even in a easier way than other scripts. But the script is not really finished because if now use a fake address you see an empty Google Maps window but it is a start. Please leave a comment this was helpful
Still 1 problem