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?

    评论

报告相同问题?

悬赏问题

  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致