Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>PHP executes on the server before getting sent to the the client. Therefor, if you can do things like this:</p> <p><code>newpoints[0] = new Array(&lt;?php echo $lattitude;?&gt;, &lt;?php echo $longitude;?&gt;, icon0, 'Place', 'Content to open');</code></p> <p>Where <code>$lattitude</code> and <code>$longitude</code> are values that you pulled out of you database with PHP.</p> <p>When this page is requested by the client, your php code executes, real values get plugged in where those php tags are making it look like the example you provided, and then it gets sent to the client. </p> <p>If you want to change these values using JS on the client, or fetch new ones from the server, let me know and I'll add an example of that.</p> <p><strong>EDIT:</strong></p> <p>Okay, in light of your comments, it sounds like you've got a few options. Here's one:</p> <p>When the user selects a category (restaurants, bars, etc) you pass that category as a url parameter and reload either the whole page, or just the map part of it (depends on your set up but might be worth investigating). Your link would look something like this:</p> <p><code>http://www.your-domain-here.com/maps.php?category=bars</code></p> <p>Maps.php is ready to catch the category using the <code>$_GET</code> array:</p> <p><code>$category = $_GET['category']; //'bars'</code> </p> <p>Your php then grabs the appropriate location data from the database (I'll leave that part to you) and sticks it in a variable that your JS-controlled map will be able to use:</p> <pre><code>//JS in maps.php - you could add this var to the window object // if you have separated js files... var locationCoords = &lt;?php echo json_encode($arrayOfCoordinatesFromDB);?&gt;; </code></pre> <p>When you page loads on the client machine, it now has an array of coordinates to use for the map ready to go in the <code>locationCoords</code> variable.</p> <p>Then, depending on which coordinates you need to display on the map, you pass them as arguments to your <code>addPoints()</code> using standard Javascript (nothing tricky here). </p> <p>That's how I'd do it. Hope that helps! </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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