Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Custom Map Projection On Leaflet

I have an application displaying a EPSG:3414 map running on Openlayers - jsfiddle working sample that works.

I am trying to implement the same on Leaflet - jsfiddle non-working, it is not working as I may have left out something or may have gotten some concept wrong.

Unfortunately, I am quite unfamiliar and am in the process of figuring out how to get this to work.

Any help would be welcome. Thanks!

Updates:

  1. map is ESRI type using ZYX and SVY21 projection):
  2. updated code here (JS fiddle not updated)
  3. the map X-Y does not start at 0/0, they are some other numbers, so it is getting more complicated, I have to do some magic number offset for each level, this works somewhat but is not ideal as the locations are not accurate, close but not accurate enough.

Leaflet Sample:

var proj = new L.Proj.CRS.TMS('EPSG:3414', "+proj=tmerc +lat_0=1.366666666666667 +lon_0=103.8333333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +ellps=WGS84 +units=m +no_defs",
    [4257.9355, 11470.3186, 64359.3062, 49067.5413], 
    {
        resolutions:[76.4372195411057,38.2186097705529,19.1093048852764,9.55465244263822,4.77732622131911,2.38866311065955,1.19433155532978,0.597165777664889,0.298450596901194]
    }
);

var map = L.map('my_map', {
    crs: proj,
    continuousWorld: true,
    worldCopyJump: false
});

map.addLayer(new L.Proj.TileLayer.TMS('http://{s}.onemap.sg/ArcGIS/rest/services/basemap/MapServer/tile/{z}/{y}/{x}', proj, {
    subdomains: ['t1', 't2'],
    tms: true,
    continuousWorld: true
}));
like image 950
Aaron Gong Avatar asked Nov 12 '22 23:11

Aaron Gong


1 Answers

Does this example

http://esri.github.io/esri-leaflet/examples/non-mercator-projection.html

or this example help

http://blog.thematicmapping.org/2012/07/using-custom-projections-with-tilecache.html

I would use firebug in firefox with the example and then look to see if there are error messages in the console.

Also I would try it on a straight web page before I put it in JS Fiddle. Just one less thing that might be interfering.

like image 68
TheSteve0 Avatar answered Nov 14 '22 22:11

TheSteve0