Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Should be fairly easy. Once you've fetched the $latitude and $longitude according to the linked example, you can use PHP to echo those values out to your Javascript code.</p> <pre><code>&lt;script type="text/javascript"&gt; function initialize() { var map; if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map_canvas")); var zoomlevel = 9; var lat= &lt;?php echo $latitude ?&gt;; var lgt= &lt;?php echo $longitude ?&gt;; map.setCenter(new GLatLng(lat, lgt), zoomlevel); ......... ............... &lt;/script&gt; </code></pre> <p>That should get you going for the script mixing part. Remember, you've to use PHP to fetch the lat/long <strong>BEFORE</strong> you attempt to output the values to your JS.</p> <p>In response to your queries, here's the general flow of code (say, in the file index.php):</p> <pre><code>&lt;?php // Code from the blog $ip = $_SERVER['REMOTE_ADDR']; ..... ....... $latitude = $res[2]; $longitude = $res[3]; ?&gt; &lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; function initialize() { var map; if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map_canvas")); var zoomlevel = 9; var lat= &lt;?php echo $latitude ?&gt;; var lgt= &lt;?php echo $longitude ?&gt;; map.setCenter(new GLatLng(lat, lgt), zoomlevel); ......... ............... } &lt;/script&gt; &lt;/head&gt; &lt;body onload="initialize()" onunload="GUnload()"&gt; ...... &lt;/body&gt; &lt;/html&gt; </code></pre> <p>See if this helps you :)</p> <p>Cheers, m^e</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload