0
votes

I'm currently developing a personal project that involves getting data from a database (specifically, coordinates) and using the data to create pushpins with Bing Maps. I have results from the coordinates query that are structured like this $coordinates[row_of_queryresult]['latitude/longitude']. I tried to put these values into a Microsoft.Maps.Pushpin object to create a dynamic pushpin based on my DB values. The map.php page is basically an echoed HTML page with a query that gets the coordinates. If I do echo '<p>'. $coordinates[0]['latitude'] . '</p>'; the value is displayed correctly. However, when doing [...] new Microsoft.Maps.Location($coordinates[0]['latitude'], $coordinates[0]['longitude'])the map doesn't load at all. Is this an escape problem? How can I write these coordinates correctly?

1

1 Answers

0
votes

Try seeing if the coordinate values are string versions of numbers, or numbers. If they are strings, wrap them with parseFloat like this:

new Microsoft.Maps.Location(parseFloat($coordinates[0]['latitude']), parseFloat($coordinates[0]['longitude']))