代码示例:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style>
#mapDiv {
/*必须指定高度*/
height: 900px;
}
</style>
<!--leaflet样式文件-->
<link rel="stylesheet" href="./js/lib/leaflet/leaflet.css" />
<!--leaflet核心JS文件--> <script type="text/javascript" src="./js/lib/leaflet/leaflet.js"></script>
<script type="text/javascript" src="./js/jquery-3.2.1.min.js"></script>
<script> </script> </head>
<body>
<div id="mapDiv">
</div> <!--脚本必须放在尾部-->
<script>
var map = L.map('mapDiv').setView([51.505, -0.09], 13);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">中科院数字与遥感研究所</a> contributors'
}).addTo(map);
var marker = L.marker([51.508, -0.09]).addTo(map);
var circle = L.circle([51.508, -0.11], {
color: 'red',
fillColor: '#f03',
fillOpacity: 0.5,
radius: 500
}).addTo(map);
circle.bindPopup("I am a circle.");
var polygon = L.polygon([
[51.509, -0.08],
[51.503, -0.06],
[51.51, -0.047]
]).addTo(map); var popup = L.popup(); function onMapClick(e) {
popup
.setLatLng(e.latlng)
.setContent("You clicked the map at " + e.latlng.toString())
.openOn(map);
} map.on('click', onMapClick); </script> </body>
</html>

leaflet入门(一)示例的更多相关文章

  1. Leaflet入门:添加点线面并导入GeoJSON数据|Tutorial of Leaflet: Adding Points, Lines, Polygons and Import GeoJSON File

    Web GIS系列: 1.搭建简易Web GIS网站:使用GeoServer+PostgreSQL+PostGIS+OpenLayers3 2.使用GeoServer+QGIS发布WMTS服务 3.使 ...

  2. Spring MVC 入门教程示例 (一)

    今天和大家分享下  Spring MVC  入门教程 首先还是从 HelloWorld  web 工程开始 -------------------------- 1.首先创建一个Maven Web工程 ...

  3. wxPython 入门开发示例

    1.背景资料 wxPython API:https://www.wxpython.org/Phoenix/docs/html/ 2.入门示例 wxPython最重要的两个概念:App与Frame,其中 ...

  4. leaflet入门(五)API翻译(下)

    L.PointConstructor(函数构造器)Properties(属性)Methods(方法) L.BoundsConstructor(函数构造器)Properties(属性)Methods(方 ...

  5. leaflet入门(四)API翻译(上)

    L.Map L.Marker L.Popup L.Map API各种类中的核心部分,用来在页面中创建地图并操纵地图. Constructor(构造器) 通过div元素和带有地图选项的描述的文字对象来实 ...

  6. Highcharts入门小示例

    一.创建条形图 1.创建div容器 <div id="container" style="min-width:800px;height:400px"> ...

  7. 复杂事件处理——Esper入门(示例程序)

    前面对Esper Quick Start & Tutorial进行了简单描述,希望各位看官能够大致了解what is Esper,甚至对how to work有朦朦胧胧的了解. 开发一个Esp ...

  8. Arduino 入门程序示例之直流电机(2015-06-15)

    概述 演示直流电机的控制. 示例程序 PWM控制直流电机 略过控制电机转停的示例啦,有需要就把这里的 PWM 换成数字口输出 HIGH 或 LOW 就行了. // ------------------ ...

  9. Arduino 入门程序示例之一片 LED(2015-06-11)

    概述 从点到线,从线到面.现在开始要来一片的 LED 了,一大波的 LED 正在到来! 示例程序 因为手头没有现成的模块,手头只有 595,所以这里每一个示例程序都是使用 74HC595 扩展 IO ...

随机推荐

  1. MYSQL分析慢查询

    mysql慢查询的日志文件路径一般为: /var/lib/mysql/slowquery.log,具体的路径可以通过mysql配置文件(/etc/my.cnf)查询,slow_query_log_fi ...

  2. Javascript 四种输出方式

    JavaScript 输出 javascript 没有任何打印或输出的函数 可以通过不同的方式输出数据 使用window.alert() 弹出警告框 使用document.write()方法将内容写到 ...

  3. Informatica_(1)安装

    安装961 server和client 0.informatica卸载保证服务(informatica9.6.1)在关闭状态:卸载客户端,应用程序-->informatica-->unin ...

  4. C++中string类

    https://blog.csdn.net/sinat_36184075/article/details/54836053 https://blog.csdn.net/fdqw_sph/article ...

  5. visual studio 2017 30天到期,不能输入注册码

    官网下载了visual studio 2017后,第一次安装没有登陆,导致只有30天试用期,虽然还在试用期内,但是无法使用注册码永久使用 解决办法: 1.注册一个微软账号,直接百度搜索“微软账号登陆” ...

  6. hdu 1026(BFS+输出路径) 我要和怪兽决斗

    http://acm.hdu.edu.cn/showproblem.php?pid=1026 模拟一个人走迷宫,起点在(0,0)位置,遇到怪兽要和他决斗,决斗时间为那个格子的数字,就是走一个格子花费时 ...

  7. guide dpdk

    Welcome to DPDK Guide! Contents: Setting up DPDK Important Prerequisites Setting up repositories Red ...

  8. 08. pt-find

    vim pt-find.cnf host=192.168.100.101port=3306user=adminpassword=admin pt-find --config pt-find.cnf d ...

  9. h5页面适配iPhone X的方法

    一.原生适配iphoneX 原生适配很简单,查看机型图:   只要用 #define KIsiPhoneX ([UIScreen mainScreen].bounds.size.height>8 ...

  10. IOS初级:NSKeyedArchiver

    NSKeyedArchiver对象归档 首先要实现<NScoding>里面的两个代理方法initWithCoder,encodeWithCoder @property (nonatomic ...