Jump to content

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
https://forums.phpfreaks.com/topic/87381-solved-google-maps-1/
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
https://forums.phpfreaks.com/topic/87381-solved-google-maps-1/#findComment-446985
Share on other sites

  • 2 weeks later...

Google has a code for outputting with php from MySQL, that is what you need. I have done that on this page.

 

http://www.mesquitechristmas.com/local/map.php

 

The addresses in the DB are geocoded to lat/long and stored in the DB with a simple PHP code then outputted to Js via XML. Just go look at the google map docs for Google Maps with PHP/MySQL.

Link to comment
https://forums.phpfreaks.com/topic/87381-solved-google-maps-1/#findComment-455275
Share on other sites

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.