Wednesday, December 9, 2015

Leaflet WMS layer custom projection on fly

Be The First To Comment
For most of the WMS mapping applications the Google Web Mercator (GWM) projection is sufficient. The GWM is default standard for web mapping and widley accepted by Bing, Google, OSM, OpenLayers(default), and Leaflets(default). However some mapping application required custom projection other than Google Mercator projection to display data. Then, how to project/re-project the data other than wms's default projection, GWM.

The following snippet shows the WMS layer custom projection in LEAFLET for  Albers equal area and UTM zone 13.

Step 1.

First of all include -
         leaflet.js
         proj4.js
         proj4leaflet.js  in following order.    

     <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css" />  
     <script src="http://cdn.leafletjs.com/leaflet-0.7/leaflet-src.js"></script>  
     <script src="//cdnjs.cloudflare.com/ajax/libs/proj4js/2.0.0/proj4.js"></script>  
     <script src="http://mapserv.utah.gov/cdn/examples/proj4leaflet.js"></script>  

Step 2: Create new Proj4Leaflet CRS

Find your desired custom projection type in http://spatialreference.org/ and punch the the projection variable in the following code snippet.









    

Friday, November 7, 2014

Tips to share a leaflet map with multiple ROIs

Be The First To Comment
Do you have a Leaflet map? Yes. Can you panned and and zoomed to a particular event or ROI in the map? Yes. Then, how can you share that map zoomed or centered with ROI/events to your webpage or email as a link? One of the answers may be set the zoom level and set view near the ROI.  Alright, what will you do if you have a map with multiple ROI/events? Do you make multiple maps with multiple zoom level and view? You can, but probably not a good idea to do that. 

The solution comes here, leaflet-hash.js, solves your needs, it is a JavaScript library written by Michael Lawrence Evans, which appends the URL hashes to web pages automatically and the hash changes with Leaflet map on drag or zoom. The hash consists of map zoom level and latitude/longitude of the center of map viewport, everything you need to share the map with focused ROI as link in following simple steps:

 

© 2011 GIS and Remote Sensing Tools, Tips and more .. ToS | Privacy Policy | Sitemap

About Me