Mutley Posted April 22, 2007 Share Posted April 22, 2007 I have a script that looks in a flat text file for an image and coordinates, then plots them on Google Maps in a DIV tooltip. I want to convert the script to database but need to know how it works in order to do so (mainly when there is 2 or more pictures under the same coordinates it will group them in the same DIV and not loads over lapping each other). Here is the code: <?php $locations = array(); $lines = file("locations.txt"); $count = 0; foreach ($lines as $line) { list($gallery,$lat,$long) = split(" ", $line); $long = trim($long); if (!array_key_exists($lat . "," . $long,$locations)) { $locations[$lat . "," . $long] = array(); } array_push($locations[$lat . "," . $long],$gallery); } foreach ($locations as $latlong => $galleries) { $size = count($galleries); $count = $count + 1; print "var marker$count = new GMarker(new GLatLng($latlong));\n"; $tooltip = "<div style='width: 205px; height: " . (55 * $size) . ";'>"; foreach ($galleries as $gallery) { $tooltip = $tooltip . "<div style='width: 205px; height: 55px;'><table width='100%'><tr><td valign='middle'><a href='images/$gallery'><img height='50' border='2' src='images/$gallery'></a></td><td align='center' valign='middle'><font size='-2'>" . str_replace("_"," ",$gallery) . "yes</font></td></tr></table></div>"; } $tooltip = $tooltip . "</div>"; print "GEvent.addListener(marker$count, 'click', function() { marker$count.openInfoWindowHtml(\"$tooltip\"); });\n"; print "map.addOverlay(marker$count);\n"; } ?> The flat file looks like: p2.png 52.372874 4.894753 mt.jpg 52.372874 4.894753 So the images are "images/mt.jpg" for example, and the next set of numbers are the coordinates. Thanks, help on finding what groups the same coordinates in a DIV would be really helpful. Link to comment https://forums.phpfreaks.com/topic/48183-converting-flat-file-to-database/ Share on other sites More sharing options...
Mutley Posted April 23, 2007 Author Share Posted April 23, 2007 ??? Link to comment https://forums.phpfreaks.com/topic/48183-converting-flat-file-to-database/#findComment-236081 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.