duancai9010 2017-04-14 03:50
浏览 77
已采纳

使用图像作为谷歌地图并给它坐标

Is there is a way in JavaScript to add offline map to a PHP/HTML page, in such a way that I am just using a JPEG image (of a map) and giving its bounds coordinates (longitude and latitude), and then somehow using those coordinates that I have set for the image (the map) to pinpoint something on it?

For Example:

  • I have an image that is 400px wide and 300px long.
  • At 1px long the latitude is 44.2353, and at 300px its 49.2539.
  • Something similar with longitude.
  • And then, code does the following:

    SetMarkerPosition(latitude, longtitude);

A marker appears on the map at the specified coordinates.

  • 写回答

1条回答 默认 最新

  • doomm4711 2017-04-14 03:56
    关注

    Yes, Google caters to this with the Google Static Maps API. You just include an img tag on your HTML page, with the source set to a URL like the following:

    <img src="https://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318&markers=color:red%7Clabel:C%7C40.718217,-73.998284">

    But with a &key=YOUR_API_KEYat the end of the src URL of the image also.

    The API documentation describes how to build the URL, what parameters you can put in it, etc.

    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记