Note that there are some explanatory texts on larger screens.

plurals
  1. PODrawing markers on map using data retrieved from my database
    text
    copied!<p>I was trying to find a solution on api guides and here as well but I've failed to find one. What I am trying to do is to use data stored in my database to draw markers on google map (api v3). Here's how I get data from my DB:</p> <pre><code>function getDevs(){ $query = " SELECT id, lat, lon, login, id_devtask FROM dev WHERE online='1'"; $result = mysql_query($query); $onlineDevs = array(); $singledev = array(); while($dev=mysql_fetch_array($result)){ $singledev['id']=$dev['id']; $singledev['lat']=$dev['lat']; $singledev['lon']=$dev['lon']; $singledev['login']=$dev['login']; $singledev['id_devtask']=$dev['id_devtask']; $onlineDevs[]=$singledev; } return $onlineDevs; } </code></pre> <p>Then I do $somerandomarray=getDevs(); on page that I need this data. It appears to work properly, I get all the wanted data. But now I have no clue how to use all the lats, lons, and logins (it's a name) to draw markers on my map. Here's my map (code taken from google's api guide):</p> <pre><code>&lt;script type="text/javascript"&gt; function initialize() { var myLatlng = new google.maps.LatLng(-25.363882,131.044922); var mapOptions = { zoom: 4, center: myLatlng } var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions); var marker = new google.maps.Marker({ position: myLatlng, map: map, title:"Hello World!" }); } google.maps.event.addDomListener(window, 'load', initialize); &lt;/script&gt; </code></pre> <p>Have you got any idea how to do that? (By the way, in future I will need to get data from a marker (probably just id) to make some post to database. )</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload