简体   繁体   English

为什么不显示图像?

[英]Why isn't the image being displayed?

I'm trying to get a static image from Bing maps for pushpins and showing location of certain individuals. 我正在尝试从Bing地图获取图钉的静态图像,并显示某些人的位置。 I'm using the imagery api that bing supplies and basically using their simple example code but I'm getting ";?> instead of the image. 我使用的是bing提供的图像API,并且基本上使用了它们的简单示例代码,但是我得到的是";?>而不是图像。

<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. 我在http://phpfiddle.org/上运行了您的代码,它仅输出图片,因此代码的格式似乎正确,但是控制台出现了401(未授权)错误。 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. 我认为您拥有的网址为: 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 : 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被拒绝。

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. 消息: 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 ? 你有吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM