Building A Map Caching Tile Server

  • View
    31.033

  • Download
    6

Embed Size (px)

DESCRIPTION

 

Text of Building A Map Caching Tile Server

  • 1. Building a Map Caching Tile Server
    • Using your own map in the Map API
    • GM/VE/YM tile scheme and projections
    • Cut tiles using ArcIMS or ArcMap
    • Optimization for fast cutting
    • Cache tiles with SQL server
    • Cache tiles using Web Server caching
    • Querying data behind tiles
  • 2. Replacing Online Map with your own map
    • Your GIS System has more accurate and up-to-date spatial data.
    • Most likely you have a mapping engine to produce maps, for example, ArcIMS or MapServer.
    • The most efficient way to serve your own map is replacing their map with yours.
    • Means generating maps according to the JavaScript APIs tile schema.
  • 3. Map APIs support of tile layers
    • Google Map (as of 2.7) has the most comprehensive support. You can:
      • Create customized tile layer and add to existing map types, such as map, satellite, hybrid.
      • Add additional map types.
      • Completely replace the default map types.
      • Add a single map image on the view port.
    • Virtual Earth (as of 5.0) has limited support. You can:
      • Create customized tile layer and add on top of default maps.
      • Can NOT replace the default maps.
    • Yahoo AJAX Map (as of 3.7) does not support custom tile layer.
      • There is a undocumented feature that can be used to substitute default tile server.
  • 4. GMap, GMapType and GTileLayer
    • GMap is the Google map instance.
    • A GMap has a collection of GMapTypes, e.g. NORMAL, SATELLITE, HYBRID
    • A GMapType has one or more GTileLayer, e.g. HYBRID maptype has two Tile Layers: one street name and one satellite image.
    • A GTileLayer is a collection of small tiled images and stitch together to form a seamless View port.
    • The API use getTileUrl function to retrieve images.
  • 5. Using Custom Tile Layers In Google Map
    • The key function is getTileUrl(tile, zoom).
      • The API will pass in a tile context, which include tile coordinates x, y and zoom level.
      • The API will retrieve the image from the return the URL and position the image on view port.
      • All Default Maps (normal, satellite, hybrid) use same mechanism to retrieve images from Googles tile server.
  • 6. Use Custom Tiles in Google Map
    • 1. Replace the default MapTypess default layers Image URL
      • G_NORMAL_MAP and G_SATELLITE _MAP has 1 tile layer, and G_HYBRID_MAP has 2 layers;
      • Simple swap the image URL with
        • G_NORMAL_MAP.getTileLayers()[0].getTileUrl=function (t , z){}
      • All other features of the default map type, including copyright information are unchanged, which is not desirable.
      • Have minimal impact on other coding dealing with Markers etc.
      • Sample: GMap/1_replace_def_url.htm.
  • 7.
    • 2. Add custom Tile Layer on top of default Map Type
      • Setup up Copyright information
        • var myCopy =new GCopyrightCollection('Data 2007');
      • Create a instance of GTileLayer
        • var myMapTileLayer = new GTileLayer( myCopy , 10, 18);
      • Override is getTileUrl(tile, zoom)
        • myMapTileLayer.getTileUrl=function(tile,zoom){..}
      • Add the tile layer into the default map type.
        • G_NORMAL_MAP.getTileLayers().push( myLayer );
      • Will still load images from Google, which may not be necessary because it may be covered by your layer.
      • Code Sample: GMap/2_add_on_top.htm
    Use Custom Tiles in Google Map
  • 8.
    • 3. Replace Tile Layers in default Map Type
      • Create a custom tile layer.
        • var myCopy =new GCopyrightCollection('Data 2007'); var myMapTileLayer = new GTileLayer( myCopy , 10, 18); myMapTileLayer.getTileUrl=function(tile,zoom){..}
      • Replace the tile layer in default map type.
        • G_NORMAL_MAP.getTileLayers() [0]= myMapTileLayer ;
      • Will NOT load images from Google. Can be placed in a external file or server script and have minimal impact on API coding.
      • Ideal for assisting non-GIS developers doing Google Map development.
      • Sample: GMap3_replace_def_layer.htm
    Use Custom Tiles in Google Map
  • 9.
    • 4. Create custom Map Type
      • Create a custom tile layer.
        • var myCopy =new GCopyrightCollection('Data 2007'); var myMapTileLayer = new GTileLayer( myCopy , 10, 18); myMapTileLayer.getTileUrl=function(tile,zoom){..}
      • Create a new Map Type
        • var myMapType = new GMapType([myMapTileLayer], new GMercatorProjection(19), "MyMap");
      • If needed, remove default Map Types before add the new type
        • map.getMapTypes().length = 0;
      • Add the new Map Type to Map
        • m ap.addMapType(myMapType );
      • Sample: GMap4_custom_maptype.htm
    Use Custom Tiles in Google Map
  • 10.
    • 5. Using Tile Overlay
      • As overlay in all map types, should be transparent layer
      • Create a custom tile layer.
        • var myMapTileLayer = new GTileLayer( myCopy , 10, 18); myMapTileLayer.getTileUrl=function(tile,zoom){..}
      • Create a Tile Overlay.
        • var myTileOverlay=new GTileLayerOverlay(myMapTileLayer);
      • Add Overlay to Map, AFTER setCenter().
        • map.addOverlay(myTileOverlay);
      • Idea for non-basemap, special subject layers, such as bus routes..
      • Sample: GMap5_tileoverlay.htm
    Use Custom Tiles in Google Map
  • 11.
    • Virtual Earth API only allows custom tile on top of default layers
      • Default Tiles are loaded from Microsoft even they are covered.
      • Functions like GTileLayerOverlay in Google Map API.
      • Opacity can be defined to allow see-through default Maps, if necessary.
      • Use the same tiling schema as Google Map V2.x.
      • Have very good documentation on Tile Schema for V4.
      • The PNG8 transparency may not rendered correctly.
    Use Custom Tiles in Virtual Earth
  • 12.
    • Add Custom Tile Layer in Virtual Earth
    • Create a VETileSourceSpecification instance.
      • var tileSourceSpec = new VETileSourceSpecification("myMap", "GetTilePath");
    • Define GetTilePath (tileContext) function.
      • tileSourceSpec.GetTilePath=function (tile){ }
    • Framework will pass tileContext with XPos, YPos, and ZoomLevel.
    • Add Tile Layer to map
      • map.AddTileLay