Virtual Earth API: using tile Layers

Source: Internet
Author: User

In the V3 version of the Virtual Earth API, we added support for custom tile layers, which allows you to add your own imagm imagery and overlays on the map.

One of our developers, Jaya Bhatia blogged aboutTile layers with the V3 Virtual Earth APIAwhile back. In the V5 Virtual Earth API, we have now simplified working with custom tile layers.

To create M tiles for Virtual Earth, you can useMSR mapcruncher. Check outStep by step tutorialAnd5 minute Demo VideoOf how to use MSR mapcruncher to generate tiles.

Once you have generated your tiles and hosted them somewhere, you are ready to create a V5 Virtual Earth API mashup with your tile layer.

For this example, I am using the tiles Jaya generated for her original example fromSeattle Metro Transit system map.

To load your custom tiles in the Virtual Earth V5 API, you first need to createVetilesourcespecificationWith a string ID and a URL to your custom layer.

VaR tilesource = new vetilesourcespecification ("seattletransit", "http://jbhatia1.members.winisp.net/SeattleTransit/%4.png ");

The URL to the tile source can have special characters which will be substituted when tiles are loaded. '% 4' is used to substitute the tile name using the Virtual Earth naming convention. MSR map cruncher generates tiles using the Virtual Earth naming convention, so we can use '% 4' as a placeholder for the name of the tile files.

You can then set other optional properties for the tile layer on yourVetilesourcespecificationObject:

Tilesource. bounds = [New velatlongrectangle (New velatlong (49,-123), new velatlong (47,-121)];
Tilesource. minzoomlevel = 2;
Tilesource. maxzoomlevel = 16;
Tilesource. Opacity = 0.6;
Tilesource. zindex = 100;

In the above sample, I setBoundsProperty which is an arrayVelatlongrectanglesWhich specify the coverage area of your tile layer.MinzoomlevelAndMaxzoomlevelProperties specify the zoom level ranges where your tiles exist. UsingBounds,Minzoomlevel, AndMaxzoomlevelCan be used to restrict where your tile layer is displayed and also improves performance because it will prevent unnecessary attempts to load tiles where they do not exist.

TheOpacityProperty allows you to specify the transparency of the tile layer. The value can range from 0 to 1, where 0 is completely transparent and 1 is opaque.

TheZindexProperty allows you to specify the Z-index for the tiles in the tile layer and allows you to control which tile layers appear over other tile layers.

Once you have finished creatingVetilesourcespecification, You can callAddtilelayerOnVemapTo add your tiles to the map. The second parameter indicates whether or not to immediately show the tile layer. In this case, it is set to true so the tile layer will be immediately visible.

Map. addtilelayer (tilesource, true );

Here is a link to the complete working example:

Virtual Earth API tile layer sample

For more information regarding the Virtual Earth APIs, seeVirtual Earth interactive SDK.

Published Tuesday, May 01,200 7 Keithkin

Filed under: Virtual Earth, Virtual Earth API, Mapcruncher

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.