I'm trying to get a static image from Bing maps for pushpins and showing location of certain individuals. I'm using the imagery api that bing supplies and basically using their simple example code but I'm getting ";?>
instead of the image.
<html>
<head>
<title>Driver Locations</title>
</head>
<body>
<?php
$latitude = "40.59507828";
$longitude = "-73.78302689";
$key = "";
$imageryBaseURL = "http://dev.virtualearth.net/REST/v1/Imagery/Map";
$pushpins = "&pp=";
$mapsize = "?mapSize=800,600";
$ppStyle = ";47;";
$imagerySet = "Road";
$JulieCP = $latitude.",".$longitude;
$JuliePP = $JulieCP.$ppStyle."JULIE";
$zoomLevel = "15";
$latitude = "40.90421779";
$longitude = "-73.86591633";
$MarkCP = $latitude.",".$longitude;
$MarkPP = $MarkCP.$ppStyle."MARK";
//http://dev.virtualearth.net/REST/v1/Imagery/Map/Road?mapSize=800,600&pp=40.59507828,-73.78302689;47;JULIE&pp=40.90421779,-73.86591633;47;MARK&key=$key
echo "<img src='".$imageryURL = $imageryBaseURL."/".$imagerySet."?mapSize=800,600".$pushpins.$MarkPP.$pushpins.$JuliePP."&key=".$key."'>";
?>
</body>
</html>
You are killing me with all these variables :) No wonder you couldn't output it correctly...
Try the below syntax instead. I started writing the variable order correctly but then gave up at the end so you will need to correct it to fit your needs. The syntax should be correct:
echo "<img src=\"{$imageryBaseUrl}/{$imagerySet}{$mapsize}{$JuliePP}{$ppStyle}{$MarkPP}&key={$key}\">"
Keep in mind that when variables are stored within double-quotes they are still evaluated, which makes it more readable without having to concatenate with the period. The curly braces are there to separate the variable names. It would all be considered one variable if the curly braces weren't there.
EDIT:
I ran your code on http://phpfiddle.org/ and it output only a picture, so the code seems to be formatted correctly, but the console came up with a 401 (unauthorized) error. Does the key need to be filled in for it to work correctly?
I think the url you have : http://dev.virtualearth.net/REST/v1/Imagery/Map/Road?mapSize=800,600&pp=40.59507828,-73.78302689;47;JULIE&pp=40.90421779,-73.86591633;47;MARK&key=$key
is denied.
The result is :
{"authenticationResultCode":"NoCredentials","brandLogoUri":"http:\/\/dev.virtualearth.net\/Branding\/logo_powered_by.png","copyright":"Copyright © 2015 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.","errorDetails":["Access was denied. You may have entered your credentials incorrectly, or you might not have access to the requested resource or operation."],"resourceSets":[],"statusCode":401,"statusDescription":"Unauthorized","traceId":"8782486bb4cc49388954a152f95ce666|HK20271556|02.00.196.1900|"}
The message : This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.
You need to give your credentials to used it. Are you have it ?