Jump to content

[SOLVED] Google Maps + 1


phpretard

Recommended Posts

I am echoing some javascript just fine but I need 1 part of the script to echo 1 then 2 then 3 and so on.

 

while($row = mysql_fetch_array($result))
  {
echo"
var marker1= new GMarker(new GLatLng($lon,$lat), markerOptions);
	map.addOverlay(marker1);
	GEvent.addListener(marker1, 'click', function() {
	marker1.openInfoWindowHtml(WINDOW_HTML1);});
";
}

 

The only change I need is marker1 and then marker2 ... according to the number of rows in the database.

 

(there are 2 instances of "marker1")

 

Could you help?

 

-Anthony

Link to comment
Share on other sites

I'll take a shot in the dark. Im not good with php/java/ajax mix, but what it seems like is you need your loop to increase the marker number. So something like

 

while($row = mysql_fetch_array($result))
  {
echo"
var marker" . $num . "= new GMarker(new GLatLng($lon,$lat), markerOptions);
	map.addOverlay(marker" . $num . ');
	GEvent.addListener(marker" . $num . ", 'click', function() {
	marker" . $num . ".openInfoWindowHtml(WINDOW_HTML" . $num . ");});
";

$num++
}

 

Sorry if this seems stupid. I figured I would help as much as possible.

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.