zoukankan      html  css  js  c++  java
  • [Javascript] Get Started with LeafletJS Mapping

    Leaflet makes creating maps in the browser dead simple. With some HTML and 3 lines of JavaScript, we can quickly have a map displaying

    // create a map in the "map" div, set the view to a given place and zoom
    var map = L.map('map').setView([51.505, -0.09], 13);
    
    // add an OpenStreetMap tile layer
    L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
        attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
    }).addTo(map);
    
    // add a marker in the given location, attach some popup content to it and open the popup
    L.marker([51.5, -0.09]).addTo(map)
        .bindPopup('A pretty CSS3 popup. <br> Easily customizable.')
        .openPopup();
    
    
    var circle = L.circle([51.508, -0.11], 500, {
        color: 'red',
        fillColor: '#f03',
        fillOpacity: 0.5
    }).addTo(map);
    
    
    var polygon = L.polygon([
        [51.509, -0.08],
        [51.503, -0.06],
        [51.51, -0.047]
    ]).addTo(map);
    <!DOCTYPE html>
    <html>
    <head>
        <meta name="description" content="HTML5 Canvas Graphics and Animation Video 1" />
        <meta charset="utf-8">
        <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css"/>
    </head>
    <body>
    <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
    <div id="map" style=" 100%; height: 630px;"></div>
    </body>
    </html>

  • 相关阅读:
    糖果传递
    流水作业调度(贪心) Johnson算法
    [CQOI2015]任务查询系统
    [CQOI2009]叶子的染色
    P4906 小奔关闹钟
    P1131 [ZJOI2007]时态同步
    P1270 “访问”美术馆
    P1272 重建道路
    [HNOI/AHOI2018]道路
    P1776 宝物筛选_NOI导刊2010提高(02)
  • 原文地址:https://www.cnblogs.com/Answer1215/p/4354846.html
Copyright © 2011-2022 走看看