3 种常用的 Google Maps 嵌入方式

在网页内嵌入地图的需求时常会用到,以下三种是最常见的方法:

优缺点比较

方法 运作方式 优点 缺点
Google Maps Embed API iframe 嵌入地图 制作简单且呈现动态呈现 嵌入 iframe 效能最差
Google Static Maps API 静态地图图片 效能最佳 只是一张图片,无法缩放、互动
Google Maps JavaScript API 参数串接地图 客制化程度最高 串接资料需要有一定的程序能力

补充
嵌入 iframe 效能最差,是因为网页虽然只发出一个请求取得 iframe 的资讯,但 iframe 这个地图网页里又会发出了许多请求,像是取得定位资讯、附近地点、背景底图......等,才有办法呈现如此多的资讯,同时也会造成网页负担。

Embedded Maps – Best for Beginners
At the end of the day if you just want to keep it simple using the Google Maps Embed API is your best option available. There is some downsides in terms of customisation and loading times but if you’re looking for a simple solution embedding your map is by far the easiest to do.

JavaScript Maps – Best for Experts
If you have a great level of control over your website’s code and know how to use JavaScript to an intermediate level using the Google Maps JavaScript API is the best option available for you. With such a wide range of control and practical applications you can integrate a map that fulfils any purpose you need it for.

Static Maps – Best overall
Google Maps Static API is the best option available overall. Out of the box using a static maps is relatively easy with fast loading times, decent customisation available and the best set up for SEO. Unless you’re looking for a very easy or highly complicated solution, using a static map is the way to go.

参考来源:
https://kiwisprout.nz/post/google-maps--embedded-static-or-js--whats-better


<<:  Excel VBA 巨集设计问题 不同表格中VLOOKUP找资料

>>:  【Day31】新加坡工作後续的时程

下载nodejs

学习nodejs的第一步..就是先去官网下载nodejs https://nodejs.org/en...

[Day 25 - Modern CSS] 指定CSS作用域,模组化开发 CSS Modules

要在 React 中撰写 CSS,为元素添加样式,除了 Styled-components,另外还有...

Day16 - 铁人付外挂前置作业 (ㄧ) - 串接文件

不管是哪一家软件公司或是金物流厂商,只要他们有提供 API 介面来服务外部网站,通常一定会有串接文件...

Day1 每个人都有一个财富自由梦

死线前的考验 大家好,身为一个工程师,做事情压死线是家常便饭,所以我昨天报名今天就开始写文章,我可...

[Day10] placeholder for d10

写在前面 placeholder for d10 placeholder for d10 place...