Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert .PNG image to tiles for Bing or Google Maps with ASP.NET?

Tags:

c#

asp.net

maps

I'm looking for a way to convert .PNGs (like this one: http://1drv.ms/1O9lrG5) to tiles that I can use with Google or Bing Maps. I'm thinking of a server side script that does this every 10 minutes (as the content of the .PNGs might change).

I know of tools like MapCruncher, but this is not what I'm looking for: I want a fully automated way that gets the relevant .PNGs, generates tiles (with the lat/long from all 4 corners) and let those be accessed by my client app.

Any ideas?

like image 893
Niels Avatar asked Jul 18 '15 12:07

Niels


2 Answers

If what you want is this: MapTilerLayer (or overlay-simple), you can use a dynamic url to render the image and set it as the source image for the overlay.

Example from Google Maps Javascript API:

function initialize() {
  var mapOptions = {
    zoom: 11,
    center: new google.maps.LatLng(62.323907, -150.109291),
    mapTypeId: google.maps.MapTypeId.SATELLITE
  };

  var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

  var swBound = new google.maps.LatLng(62.281819, -150.287132);
  var neBound = new google.maps.LatLng(62.400471, -150.005608);
  var bounds = new google.maps.LatLngBounds(swBound, neBound);

  // THE DYNAMIC IMAGE URL
  var srcImage = 'http://your.url/image.ashx';

  // The custom USGSOverlay object contains the USGS image,
  // the bounds of the image, and a reference to the map.
  overlay = new USGSOverlay(bounds, srcImage, map);
}
like image 134
Juliano Nunes Silva Oliveira Avatar answered Nov 16 '22 06:11

Juliano Nunes Silva Oliveira


Unless you want to write the slicing code yourself, a possibility would be to use the older DeepZoomTools.dll.

You can get the .dll by downloading deep zoom composer and pulling it from it's bin.

Here's a link to a blog showing how to programmatically create the tiles.

I used it a few years ago for a project to good effect. If needed, I could try and find the code out.

like image 40
Chris W Avatar answered Nov 16 '22 06:11

Chris W