I created a while loop that produces multiple predefined circles on Google Maps. Each circle is a different circle based on other predefined information. My problem is that when I create a key/value pair in citymap it won’t pass through when I create the actual circle. Google debugger returns with Uncaught SyntaxError: Unexpected token ILLEGAL wherever the colors is written. Here is the code.
This part is in a while loop.
citymap["<?php echo ${'location_' . $e};?>"] = {
center: new google.maps.LatLng(<?php echo ${'coordinates_' . $e};?>),
population: <?php echo ${'radius_' . $e}; ?>,
colors : <?php echo $color; ?>
};
And here is the code that constructs the circles.
for (var city in citymap) {
// Construct the circle for each value in a location.
var populationOptions =
{
strokeColor: citymap[city].colors,
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: citymap[city].colors,
fillOpacity: 0.35,
map: map,
center: citymap[city].center,
radius: citymap[city].population
};
cityCircle = new google.maps.Circle(populationOptions);
}
The error is probably caused by the PHP part. View page source and see the js code produced by PHP and make sure that it is a valid JS array and doesn’t have any syntax errors etc.