Inserting JavaScript into PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
valleyfederal
Forum Newbie
Posts: 3
Joined: Mon Jul 16, 2007 8:24 pm

Inserting JavaScript into PHP

Post by valleyfederal »

I'm trying to write a PHP script that creates an XML file (KML format)
that can be interpreted by Google Maps. However, I don't have the
coordinate information for my data, so I need to geocode the address.

However, Google Maps only uses JavaScript for geocoding addresses, and I've
been unsuccessful in inserting the JavaScript function into the PHP code.
Any help would be greatly appreciated.

This is the JavaScript function used to geocode the address.

Code: Select all

function showAddress(address) {
  geocoder.getLatLng(
    address,
    function(point) {
        var marker = new GMarker(point);
        map.addOverlay(marker);      
    }
  );
}

This is the relevant part of the PHP code that defines the coordinates.

Code: Select all

$Coordinates->appendChild($dom->createTextNode(/* Insert JavaScript here */));
I've tried various ways to successfully syntax the code but none have worked. None of the forums out there talk about this specific problem.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

You need to use Javascript to get the geocodes first, then post that to a PHP script.
Post Reply