doudan1123 2015-08-25 01:32
浏览 49

为什么不显示图像?

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>
  • 写回答

2条回答 默认 最新

  • dqx24298 2015-08-25 02:13
    关注

    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?

    评论

报告相同问题?