My guess is your lat/long data is incorrect... Can we see the actual data that "/php/phpsqlajax.php" is outputting? Perhaps a link to your map?
On Feb 25, 10:35 am, Ivan <[email protected]> wrote: > Hi Guys, > > I am trying to get the right coordinates for my markers. I am using > php sql to get the marker points but they are displayed in an area out > of the map. Can anyone help me point out whats going on with the code > below...? I am creating 'lat' FLOAT(10,8) default null in sql query > > <?php > require("phpsqlajax_db.php"); > > function parseToXML($htmlStr) > { > $xmlStr=str_replace('<','<',$htmlStr); > $xmlStr=str_replace('>','>',$xmlStr); > $xmlStr=str_replace('"','"',$xmlStr); > $xmlStr=str_replace("'",''',$xmlStr); > $xmlStr=str_replace("&",'&',$xmlStr); > return $xmlStr; > > } > > // Opens a connection to a MySQL server > $connection=mysql_connect (localhost, $username, $password); > if (!$connection) { > die('Not connected : ' . mysql_error()); > > } > > // Set the active MySQL database > $db_selected = mysql_select_db($database, $connection); > if (!$db_selected) { > die ('Can\'t use db : ' . mysql_error()); > > } > > // Select all the rows in the markers table > $query = "SELECT * FROM markers WHERE 1"; > $result = mysql_query($query); > if (!$result) { > die('Invalid query: ' . mysql_error()); > > } > > //header("Content-type: text/xml"); > > // Start XML file, echo parent node > echo '<markers>'; > > // Iterate through the rows, printing XML nodes for each > while ($row = @mysql_fetch_assoc($result)){ > // ADD TO XML DOCUMENT NODE > echo '<marker '; > echo 'name="' . parseToXML($row['placename']) . '" '; > echo 'address="' . parseToXML($row['address']) . '" '; > echo 'lat="' . $row['lat'] . '" '; > echo 'lng="' . $row['lng'] . '" '; > echo 'icon="http://www.mysite.com/images/icons/'. $row > ['uploadedicon'] . '" '; > echo 'image="' . $row['uploadedimage'] . '" '; > echo 'html="' . $row['html'] . '" '; > echo '/>'; > > } > > // End XML file > echo '</markers>'; > > ?> > > function load_sqlajax(){ > > GDownloadUrl("php/phpsqlajax.php", function(data) { > var xml = GXml.parse(data); > var markers = xml.documentElement.getElementsByTagName("marker"); > for (var i = 0; i < markers.length; i++) { > > var name = markers[i].getAttribute("name"); > var address = markers[i].getAttribute("address"); > var image = markers[i].getAttribute("image"); > // var video = markers[i].getAttribute("video"); > var video = "asdasda"; > var html = markers[i].getAttribute("html"); > > var lat = markers[i].getAttribute("lat"); > var lng = markers[i].getAttribute("lng"); > > var point = new GLatLng(parseFloat(markers[i].getAttribute > ("lat")), > parseFloat(markers[i].getAttribute > ("lng"))); > > var iconObj = new GIcon(); > iconObj.image = markers[i].getAttribute("icon"); > iconObj.iconSize = new GSize(23,33); > iconObj.iconAnchor = new GPoint(5,33); > iconObj.infoWindowAnchor = new GPoint(9, 2); > > var marker = createMarkerx > (lat,lng,point,name,image,html,iconObj,video); > > map.addOverlay(marker); > } > > }); > } > > function createMarkerx(lat,lng,point,name,image,html,iconObj,video) > > { > > var marker = new GMarker(point,iconObj); > // === store the name so that the tooltip function can use it === > > return marker; > > } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
