How to use Google map data in the Google Maps API

Source: Internet
Author: User
How can I use Google map data in the Google Maps API?

This is almost the most common question I have heard about Google Maps APIs. As we all know, Google Maps does not have a detailed map of China. In China, we only have a unique Google map website that provides a detailed map of China. The reason for this situation has not been officially explained by Google and Google, but we can probably guess it by ourselves. We will not say much about it.

Question: How can we use a detailed map of China in the Google Maps API? Previously, I always answered this question. Google Maps provides APIs that are compatible with the Google Maps API syntax. The only problem is that they are not stable. This method is actually not good, because you need to consider how to switch between two different objects in the code, the code logic will become very complicated.

However, because Google Maps's current scaling level and switching mode are already exactly the same as Google Maps. Therefore, we have a very good solution, that is, to directly use the map block of Google Maps to build a custom map type of Google Maps API.

The following is an example of using Google map in the Google Maps API from Anthony Wong (four options are displayed for the map type, and the fourth ditu is the Google Map button ):

The core code is:

var copyright = new GCopyright(1, new GLatLngBounds(new GLatLng(-90, -180),
new GLatLng(90, 180)),
0, "Map data: В2007 Mapabc.com");
var copyrightCollection = new GCopyrightCollection("В2007 Google - ");
copyrightCollection.addCopyright(copyright);
var dituTileLayer = new GTileLayer(copyrightCollection, 1, 17);
dituTileLayer.getTileUrl = function(tile, zoom) {
return "http://mapgoogle.mapabc.com/googlechina/maptile?v=w2.52&x=" +
tile.x + "&y=" + tile.y + "&zoom=" + (17-zoom);
};

// Using a map type:
var dituMapType = new GMapType([dituTileLayer],
new GMercatorProjection(23), "Ditu", { shortName: "ditu", alt: "Show maps from Google China" });
map.addMapType(dituMapType);

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.