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 9230073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:44:01+00:00 2026-06-18T05:44:01+00:00

In php, I create a string that is transferred into a javascript array of

  • 0

In php, I create a string that is transferred into a javascript array of objects:

<?php
$markers = '';
while($loc = mysql_fetch_assoc($qry)){
    $markers .= "{id:'".$loc['id']."', title:'".$loc['city']."', pos: new google.maps.LatLng(".$loc['latitude'].",".$loc['longitude'].")},";
}
?>

In the initialize function of the Google Maps api in javascript:

<script type="text/javascript">
    <?php
    if($markers){
        echo 'var locations     = [' . rtrim($markers, ",") . ']';
        unset($markers);
    }
    ?>  

    //...

    //add old markers
    var markers = new Array();
    for (var i=0; i < locations.length; i++)
    {
        marker_stack[ locations[i].id ] = new google.maps.Marker({
            map: map,
            position: locations[i].pos,
            title: locations[i].title
        });
    }

    //...

</script>

I fill an array with markers, because I may need to delete some of them later. When I do that, I just want to refer to the marker_stack array with the id that I want to delete.

The error message that I get from the above code is in a js file on Google’s server:

Uncaught Error: Ungültiger Wert für Bauunternehmer-Parameter 0: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object] main.js:36
  • 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-06-18T05:44:02+00:00Added an answer on June 18, 2026 at 5:44 am

    The issue here is that your pos: property is a string: new google.maps.LatLng(51,0)
    and you can’t pass a string to a Marker constructor.

    The solution is to set pos_lat and pos_lng as numbers and use those in the constructor:

    <?php
    $markers = '';
    while($loc = mysql_fetch_assoc($qry)){
        $markers .= "{id:'".$loc['id']."', title:'".$loc['city']."', pos_lat: ".$loc['latitude'].", pos_lng: ".$loc['longitude']."},";
    }
    ?>
    

     

    for (var i=0; i < locations.length; i++)
        {
            marker_stack[ locations[i].id ] = new google.maps.Marker({
                map: map,
                position: new google.maps.LatLng(locations[i].pos_lat,locations[i].pos_lng),
                title: locations[i].title
            });
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i would like to create a JavaScript string that holds a dynamic php page
In PHP I have an array of bytes that I want to turn into
I am trying to create a javascript countdown timer; I have a string that
Heres a simple php script that generates some XML: <?php // create doctype $dom
I am using php to create url shorten website. Within that script I am
I have a script that parse the database and create php classes to work
I have a string that must fit into a box, and must be at
Using PHP and/or Codeigniter, I want to create some string templates to be store
I am working in a PHP app we have a particular string that we
I'm Trying to get a php string to break down into individual words, search

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.