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
"http://maps.google.com/maps?file=api&v=2.x&key=".$xoopsModuleConfig['api']."" type="text/javascript">n";
        
echo"text/javascript">n";
        echo
"//;
        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
"n";

        echo
""._MD_ADDNEWPOINT."";
            echo 
"index.php">n";
        echo 
"";
        echo 
""._MD_LOCATION."";
        echo 
"";    
        echo 
""._MD_SITETITLE."";//
         
echo "._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 
".$lid." selected=".$lid.">".$title2.$lid."";
                    } echo  
" ";//
        
echo ""._MD_LONGITUDE."";
                    echo 
"n";    
        echo 
""._MD_LATITUDE."";
            echo 
"n";    
        echo 
""._MD_ZOOM."";
            echo 
"n";    
        echo 
""._MD_CATEGORYC."";
            echo 
"";
        
$count_msg count($entry);
        for ( 
$i 0$i $count_msg$i++ ) {
            echo 
".$entry[$i]['map_id']."'>".$entry[$i]['name']."";
        }
        echo 
"n";    
        echo 
""._MD_DESCRIPTIONC."";
        echo 
"";
        
xoopsCodeTarea("description",60,8);
        
xoopsSmilies("description");
            echo 
"n";
        echo 
"hidden" name="op" value="pointInsert">n";
        
        echo 
"._MD_ADD."' accesskey="s" />";        
        
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 .= "";
        
$errormsg .= _MD_ERRORTITLE."";
        
$error =1;
    }

    
// Check if Description exist
    
if ( $description == "" ) {
        
$errormsg .= "";
        
$errormsg .= _MD_ERRORDESC."";
        
$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

357 user(s) are online (284 user(s) are browsing Support Forums)


Members: 0


Guests: 357


more...

Donat-O-Meter

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

Latest GitHub Commits