Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7679637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:55:26+00:00 2026-05-31T17:55:26+00:00

All right, I’ll try to explain my problem as clearly as I can. I

  • 0

All right, I’ll try to explain my problem as clearly as I can. I already tried a lot of possible solution but never happen to find the right one.
I also want to say this is a tutorial for me, i am just a beginner in combining JS, PHP and GMAPv3 APIs.
I hope that someone can help me in solving this.
That being said, here is my code with a few lines to explain what i want to do.

The problem involves 3 main files.

1) process.php (this file generates an array of coordinates)

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>MyTest</title>
    <link rel="stylesheet" type="text/css" href="css/content.css" />
    <script type="text/JavaScript" src="js/gmapinit.js"></script>
</head>
<body>
    <?php
    ...after some lines of code i build this...
    $myarray = ...;
    ...and here i move to the second file
    echo "<input type=\"button\" value=\"Next!\" onClick=\"location.href='map.html'\">";
    ?>
</body>

2) map.html (this file is responsible for drawing the map on the screen)

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <title>MyTest</title>
    <link rel=stylesheet type="text/css" href="css/googlemap.css" />
    <script type="text/javascript"
            src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCbNM4y2fJ4AdCoXcWW-sGXPl5nXaJogPA&sensor=false">
    </script>
    <script type="text/JavaScript" src="js/gmapinit.js"></script>
    <script type="text/javascript" src="http://www.google.com/jsapi"></script>
</head>
<body onLoad="init_map_and_markers()">
    <div id="map_canvas">
    </div>       
</body>

2) gmapinit.js (the javascript file that builds the map and “should” get the array as parameter to draw markers accordingly)

function init_map_and_markers() {
var global_markers = [];

var infowindow = new google.maps.InfoWindow({});
var latlng = new google.maps.LatLng(27.059126, -41.044922);
var myOptions = {
    zoom: 3,
    center: latlng,
    mapTypeId: google.maps.MapTypeId.HYBRID
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
    myOptions);

//Of course here myarray is not defined but the point is making it available here so i can loop through it and place my markers!

for (var i = 0; i < markers.length; i++) {
    for(var count = myarray.length - 1; count >= 0; --count) { 
        var o = myarray[count];
        var lat = parseFloat(o.lat);
        var lng = parseFloat(o.lng);
        var markerdata = o.user;

        var myLatlng = new google.maps.LatLng(lat, lng);

        var contentString = "<html><body><div><p><h2>" + markerdata + "</h2></p></div></body></html>";

        var marker = new google.maps.Marker({
            position: myLatlng,
            map: map,
            title: "Coordinates: " + lat + " , " + lng + " | Marker Data: " + markerdata
        });

        marker['infowindow'] = contentString;

        global_markers[i] = marker;

        google.maps.event.addListener(global_markers[i], 'click', function() {
            infowindow.setContent(this['infowindow']);
            infowindow.open(map, this);
        });
    }    
}

}

So the main question is, how can i pass $myarray from process.php to map.html making it available to gmapinit.js???

I am asking this avoiding to write down all code-tests i did because maybe my all thinking is wrong…that’s why i am writing down the most “clean” code i got.

Code possible solutions would be much appreciated, and don’t hesitate to ask for details if i missed something.

Thanks a lot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:55:27+00:00Added an answer on May 31, 2026 at 5:55 pm

    you may use the markers as argument for init_map_and_markers()

    <body onLoad="init_map_and_markers(<?php echo json_encode($phpArrayMarkersDefinition); ?>)">
    

    ..then you may access this array inside the function:

    function init_map_and_markers(markers) 
    {
      //....
      for(var i=0;i<markers.length;++i)
      {
        //create the markers here
      }
    
      //....
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to send values to the GLSL, int is just all right, but
All right so I tried using the button set. So fair, I have been
All right, I've seen some posts asking almost the same thing but the points
All right, you guys were very helpful with my last question, so I'll try
All right. The problem here is pretty abstract. Bear with me. I have a
Possible Duplicate: What Advantages of Extension Methods have you found? All right, first of
All right this is kind of embarrassing, but I am not sure what is
All right, so previously I asked... SOAP Prototype AJAX SOAPAction Header Question (can't hyperlink
All right, I've seen this multiple times in the past, but most recently with
All right all, So I've got a UITableView that is inited in applicationDidFinishLaunching like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.