[Javascript] Get Started with Leafletjs Mapping

Source: Internet
Author: User

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

//Create a map in the ' map ' div, set the view to a given place and zoomvarMap = l.map (' map '). Setview ([51.505,-0.09], 13);//Add an OpenStreetMap tile layerL.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 popupL.marker ([51.5,-0.09]). AddTo (map). Bindpopup (' A pretty CSS3 popup. <br> easily customizable. '). Openpopup ();varCircle = L.circle ([51.508,-0.11], 500, {color:' Red ', FillColor:' #f03 ', fillopacity:0.5}). AddTo (map);varPolygon =L.polygon ([[51.509,-0.08],    [51.503,-0.06],    [51.51,-0.047]]). AddTo (map);

<!DOCTYPE HTML><HTML><Head>    <Metaname= "description"content= "HTML5 Canvas Graphics and Animation Video 1" />    <MetaCharSet= "Utf-8">    <Linkrel= "stylesheet"href= "//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css"/></Head><Body><Scriptsrc= "//cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></Script><DivID= "Map"style= "width:100%; height:630px;"></Div></Body></HTML>

[Javascript] Get Started with Leafletjs Mapping

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.