Google Maps Basics

Category: /blog /website
Tags: website

I read this book to learn the basics.

Basic skeleton

create a new Map object

var myMap = new google.maps.Map();

To specify a point in maps:

myLocation = new google.maps.LatLng($lat, $lng);

set Zoom: myMap.setZoom(12)

Sample files:

Localization

<script
        src="http://maps.googleapis.com/maps/api/js?language=zh-CN">
</script>

The language code list is at https://developers.google.com/maps/faq#languagesupport

<script
        src="http://maps.googleapis.com/maps/api/js?region=gr">
</script>

For a list of region codes, visit http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry.

Google Maps Overlays

Zooming with mouse

map.enableKeyDragZoom(); hold one of the control keys (SHIFT, CTRL, ALT) and use mouse to draw a rectangle to zoom to this region.

KeyDragZoom Examples

Controls

var options = {
    scaleControl: true,
    panControl: true/false,
    zoomControl: true,
    mapTypeControl: true,
    streetViewControl: true, 
    overviewMapControl: true,
}

讨论

提示

  • 如果看不到讨论部分, 请暂时关掉adblock in Firefox/Chrome
  • 本网站使用Javascript实现评论功能, 此处外链对提高您的网站PR没有帮助. (潜台词: 请不要灌水, 谢谢)