Re: Problem appending values to an object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, August 22, 2005 10:04 am, David Pollack wrote:
> I have a database with two tables. One is a table of events and the
> other is a table of locations.  I'm creating a google map with the
> table of locations and would like to list the events at each place.
> I'm using mambo and the following query to get the data...
>
> 		$query2 = "SELECT #__places.*, #__events.title"
> 		. "\n FROM #__places, #__events"
> 		. "\n WHERE #__places.name = #__events.adresse_info"
> 		. "\n AND  published='1'"
> 		. "\n ORDER BY ordering"
> 		;
>
> 		$database->setQuery( $query2 );
> 		$rows = $database->loadObjectList();
>
> This returns the variable $rows with all the data I need to plot the
> points on the map and the titles of the events going on at each of
> these places. $rows is an array containing objects of each row of
> data. The problem I'm having is that some places have multiple events
> and when I plot the points, it'll plot multiple points for those
> places.

That may not be a problem, since the multiple points may simply
over-write each other, and you won't know the difference visually...

What I did in one similar situation, not yet finished, was to plot a
BIGGER dot (or whatever) when there were multiple "things" at one
point.

The more things, the bigger the dot.

You could even use ORDER BY (abs(lat) + abs(lng)) to get points "near"
each other to be sequential so that... [continued]

> What I'd like to do is collapse the array $rows so that when the name
> of a place is duplicated only the title of the event is added and not
> all the other duplicate info. I feel like this may be possible either
> through manipulation of the data in PHP or by using another sql query.
> Any help would be greatly appreciated.
>
> Here's some extra info in case you need it:
>
> // The call used to map all the points
>  <?
> 	$j = 0;

$unique = array();

> 	foreach ($rows as $row) {

if (!isset($unique[$row->lng . '.' $row->lat])){

> ?>
>
> 	var html = createHTML("<? echo "$row->name"; ?>", "<? echo
> "$row->address"; ?>", "<? echo "$row->suburb"; ?>", "<? echo
> "$row->state"; ?>", "<? echo "$row->postcode"; ?>");
> 	var point = new GPoint(<? echo "$row->lng"; ?>,<? echo "$row->lat";
> ?>);
> 	var marker = createMarker(point, html);
> 	map.addOverlay(marker);
> 		<?
> 		if($sname == $row->name) {
> 		?>
> 	marker.openInfoWindowHtml(html);
>
> <?

$unique[$row->lng . '.' . $row->lat] = true;
}

> 		}
> 	}
> ?>
>
> And here's the URL of the site

You could also do some basic arithmetic on the lng/lat and "cheat" the
dots over/up a bit if they are "too close" to a previously-used dot.

You may also want to consider trying to get each dot to have a number
($j leaps to mind) or something in the balloon image, so that you can
put corresponding numbers in the image and in the sidebar HTML so the
user can match up the map with the specials.

Otherwise, the connection between mapped points and drink specials is
too tenuous.

[continued]... and if you've used the ORDER BY suggested above, and
the bigger dots, you can have, EG, 5,6 in a balloon instead of just 5,
and then the nearby things will be listed together in an intuitive
way.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux