1
slitzx
Google map module
  • 2010/1/20 17:55

  • slitzx

  • Just popping in

  • Posts: 7

  • Since: 2010/1/12


hi, i am currently using googlemaps module and mxdirectory. I am trying to link the map to the id of a particular listing i posted in with my mxdirectory, however, i had faced some troubles. i tried to add in a drop down menu to get the title when the admin wants to add a new point, however, the result is not being uploaded to sqldb.
Resized Image

as attached the lid is blank, please help me =)
this is the add point page
Resized Image

//Add in a new point
function pointAdd()
{
    global 
$xoopsDB$xoopsModule$xoopsModuleConfig;
    
    
$result2 $xoopsDB->query("select count(*) from ".$xoopsDB->prefix("gmap_category")."");
    list(
$numrows2) = $xoopsDB->fetchRow($result2);
    if ( 
$numrows2 ) {    
        
$result1 $xoopsDB->query("select map_id, name from ".$xoopsDB->prefix("gmap_category")."");
            
$i 0;
        while (
$array $xoopsDB->fetchArray($result1)) {
            
$entry[$i]['map_id']   = $array['map_id'];
            
$entry[$i]['name']   = $array['name'];
            
$i++;
        }  
        
xoops_cp_header();
        echo
"<script src="http://maps.google.com/maps?file=api&v=2.x&key=".$xoopsModuleConfig['api']."" type="text/javascript"></script >n";
        
echo"<script type="text/javascript">n";
        echo
"//<![CDATA[ n";
        echo
"function loadMap(){n";
        
//echo"function GPoint2(x,y) { return new GLatLng(y,x); }n";
        
echo"var map = new GMap2(document.getElementById("map"));n";
        echo
"map.addControl(new GLargeMapControl());n";
        echo
"map.addControl(new GMapTypeControl());n";
        echo
"map.setCenter(new GLatLng(0, 0), 1);n";
        echo
"GEvent.addListener(map, "click", function(overlay, point){n";
        echo
"map.clearOverlays();n";
        
//echo"GEvent.addListener(map, 'zoomend', function() {n";
        
echo"document.getElementById("zoom").value = map.getZoom();n";
        
//echo"});n";    
        
echo"if (point) {n";
        echo
"map.addOverlay(new GMarker(point,{draggable:true}));n";
        echo
"map.panTo(point);n";
        echo
"lat = point.y;n";
        echo
"lon = point.x;n";
        echo
"document.getElementById("lat").value = lat;n";
        echo
"document.getElementById("lon").value = lon;n";
        echo
"}n";
        echo
"});n";
        echo
"}n";
        echo
"// arrange for our onload handler to 'listen' for onload eventsn";
        echo
"if (window.attachEvent) {n";
        echo
"window.attachEvent("onload", function() {n";
        echo
"loadMap();    // Internet Explorern";
        echo
"});n";
        echo
"} else {n";
        echo
"window.addEventListener("load", function() {n";
        echo
"loadMap(); // Firefox and standard browsersn";
        echo
"}, false);n";
        echo
"}n";
        echo
"//]]>n";
        echo
"</script >n";

        echo
"<table width='100%' class='outer' cellspacing='1'><tr><th colspan='2'>"._MD_ADDNEWPOINT."</th></tr>";
            echo 
"<form method=post action="index.php">n";
        echo 
"<tr valign='top' align='center'><td class='head' colspan='2'><div id='map' style='height: 400px'></div ></td></tr>";
        echo 
"<tr valign='top' align='left'><td class='head'>"._MD_LOCATION."</td>";
        echo 
"<td class='even'><input type=text name=title size=50 maxlength=100></td>";    
        echo 
"<tr valign='top' align='left'><td class='head'>"._MD_SITETITLE."</td>";//
         
echo "<td class='even'><select name="._MD_SITETITLE."   size='1' ><";
         
$getmxlid=$xoopsDB->query("select lid, title from ".$xoopsDB->prefix("xdir_links")."");
        while (
$mxlink $xoopsDB->fetchArray($getmxlid) ) {
    
$lid=$mxlink['lid'];
    
$title2=$mxlink['title'];
    
        echo 
"<option value=".$lid." selected=".$lid.">".$title2.$lid."</option>";
                    } echo  
" </select></td>";//
        
echo "<tr valign='top' align='left'><td class='head'>"._MD_LONGITUDE."</td>";
                    echo 
"<td class='even'><input id=lon type=text name=lon size=50 maxlength=250></td><tr>n";    
        echo 
"<tr valign='top' align='left'><td class='head'>"._MD_LATITUDE."</td>";
            echo 
"<td class='even'><input id=lat type=text name=lat size=50 maxlength=250></td><tr>n";    
        echo 
"<tr valign='top' align='left'><td class='head'>"._MD_ZOOM."</td>";
            echo 
"<td class='even'><input id=zoom type=text name=zoom size=50 maxlength=250></td><tr>n";    
        echo 
"<tr valign='top' align='left'><td class='head'>"._MD_CATEGORYC."</td>";
            echo 
"<td class='even'><select size='1' name='category'>";
        
$count_msg count($entry);
        for ( 
$i 0$i $count_msg$i++ ) {
            echo 
"<option value='".$entry[$i]['map_id']."'>".$entry[$i]['name']."</option>";
        }
        echo 
"</select></td></tr>n";    
        echo 
"<tr valign='top' align='left'><td class='head'>"._MD_DESCRIPTIONC."</td>";
        echo 
"<td class='even'>";
        
xoopsCodeTarea("description",60,8);
        
xoopsSmilies("description");
            echo 
"</td></tr>n";
        echo 
"<input type="hidden" name="op" value="pointInsert"></input>n";
        
        echo 
"<tr valign='top' align='left'><td class='head'></td><td class='even'><input type='submit' class='formButton' name='post'  id='post' value='"._MD_ADD."' accesskey="s" /></form></td></tr></table>";        
        
xoops_cp_footer();
       }else{
        
redirect_header("index.php?op=catAdd",1,_MD_NOCATSADD);
    }
}

//Insert the new point into the DB
function pointInsert()
{
    global 
$xoopsConfig$xoopsDB$myts$xoopsUser$xoopsModule$eh;
    
$title $myts->makeTboxData4Save($_POST["title"]);
    
$lat $myts->makeTboxData4Save($_POST["lat"]);
    
$lon $myts->makeTboxData4Save($_POST["lon"]);
    
$zoom $myts->makeTboxData4Save($_POST["zoom"]);
    
$category $myts->makeTboxData4Save($_POST["category"]);
    
$description $myts->makeTareaData4Save($_POST["description"]);
    
$lid $myts->makeTboxData4Save($_POST["lid"]);
    
$submitter $xoopsUser->uid();
    
$date time();
    
$errormsg '';
    
// Check if Title exist
    
    
if ( $title == "" ) {
        
$errormsg .= "<h4 style='color: #ff0000'>";
        
$errormsg .= _MD_ERRORTITLE."</h4>";
        
$error =1;
    }

    
// Check if Description exist
    
if ( $description == "" ) {
        
$errormsg .= "<h4 style='color: #ff0000'>";
        
$errormsg .= _MD_ERRORDESC."</h4>";
        
$error =1;
    }
    if ( 
$error == ) {
        
xoops_cp_header();
        echo 
$errormsg;
        
xoops_cp_footer();
        exit();
    }
    list(
$order) = $xoopsDB->fetchRow($xoopsDB->query("SELECT MAX(`order`) FROM ".$xoopsDB->prefix("gmap_points")." WHERE `map_id` = ".$category));
    
$order++;
    
$sql "INSERT INTO ".$xoopsDB->prefix("gmap_points")." (`map_id` , `lat` , `lon` , `title` , `html` , `zoom` , `submitter` , `status` , `date`, `order`, `lid`) VALUES ('$category', '$lat', '$lon', '$title', '$description', '$zoom','$submitter', '1', '$date', '$order', '$lid')";
    
$xoopsDB->query($sql) or $eh->show("0013");
    if ( 
$newid == ) {
    
$newid $xoopsDB->getInsertId();
    }
    
redirect_header("index.php?op=linksConfigMenu",1,_MD_NEWPOINTADDED);
}

thank you very much !

Login

Who's Online

203 user(s) are online (129 user(s) are browsing Support Forums)


Members: 0


Guests: 203


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits