Create Google Map Markers with PHP

All, I've got some locations stored in my database with long and lat coordinates. I'm debating between creating a map for each one of the locations or adding markers for all of them. Any advice would be appreciated on that idea but my issue is that I'm getting these values from my mySQL database. It looks like the only way you can actually add these is through javascript. Do I need to pass in the coordinates to a javascript function to create the markers? How would that look? Any suggestions are appreciated!


You're correct. You have to fetch the data from the database and use something along the line of:

  function initialize() {
    var myLatlng = new google.maps.LatLng(<?php echo $lat; ?>,<?php echo $long; ?>);
    var myOptions = {
      zoom: 4,
      center: myLatlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    var marker = new google.maps.Marker({
        position: myLatlng, 
        map: map,
        title:"Hello World!"

In a < script type="text/javascript">-tag on the page. The above is taken from, so you'll have to adapt it to your needs.

Need Your Help

Use a WPF Style to simplify repetitive MultiBindings

wpf xaml multibinding

I am displaying the results of several tests. There are 2 variables on each test, and the text and color of the displayed results vary with both. I have this working, but there's a lot of repetitive

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.