2Rossko,  forgive me my stupidity adding this topic to not appropriate
forum, as I believe you hint on this. As I'm amateur programmer, my
logic was very simple - I have a trouble with Google Map that does not
load markers, the issue appeared while I edited JS file - a part of
Google Maps JavaScript API v3 - so I posted question to Google Maps
JavaScript API v3 group.
BUT! Anyway I thank to everybody, cuz I found solution due to you.
Main issue was exactly the fact that I loaded empty variables to file
that formed this variables.

The solution I found is maybe not perfect but. Here it is.

In case your php array contains names of variables that are initiated
in external JS file:
1. Load your php variable in JS array as text values adding quotes to
them I did it via
var clean_cities = new Array("<?php echo implode('","',$clean_cities);?
>");
2. Loop this array in external JS file in place after your JS
variables are filled with values.
3. Collect new JS array with variables' names based on condition that
the JS array you collected in PHP contain text that correspond this
variable name, I did it this way:
var cities = [];
        for (var i = 0; i < clean_cities.length; i++) {

        if (clean_cities[i] == "kiev") {
        cities.push(kiev);
        } else if (clean_cities[i] == "lvov") {
        cities.push(lvov);
        }

}
Thus you create an JS array filled with variables that got value in JS
file.

Thanks once again to everybody and forgive me if I placed this
question in wrong place. ;)

On 10 Грд, 22:14, Rossko <[email protected]> wrote:
> > well I wrote an array of names -  var cities = new
> > Array(kiev,kharkov,lvov,odessa);
>
> That's an array of javascript variables.  One called 'kiev' , one
> called 'kharkov', etc.
> At the time you do that, they haven't been defined at all.
>
> Think about what you would expect this code to do :
>    var x = "banana";
>    var myArray = new Array(x);
>    alert( myArray[0] );
>
> If you want have an array of stringsyou might do
>      var cities = new Array("kiev","kharkov",....
>
> None of this has anything to do with the maps API.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to