Google maps api demo

demo:

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <title>KML Layers</title>
    <style>
      html, body, #map-canvas {
        height: 100%;
        margin: 0px;
        padding: 0px
      }
    </style>
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
    <script>
function initialize() {
  var chicago = new google.maps.LatLng(41.875696,-87.624207);
  var mapOptions = {
    zoom: 11,
    center: chicago
  }

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

  var ctaLayer = new google.maps.KmlLayer({
    url: ‘http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml‘
  });
  ctaLayer.setMap(map);
}

google.maps.event.addDomListener(window, ‘load‘, initialize);

    </script>
  </head>
  <body>
    <div id="map-canvas"></div>
  </body>
</html>

cta.kml

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<!-- Data derived from:
       Ed Knittel - || tastypopsicle.com
       Feel free to use this file for your own purposes.
       Just leave the comments and credits when doing so.
-->
  <Document>
    <name>Chicago Transit Map</name>
    <description>Chicago Transit Authority train lines</description>

    <Style id="blueLine">
      <LineStyle>
        <color>ffff0000</color>
        <width>4</width>
      </LineStyle>
    </Style>
    <Style id="redLine">
      <LineStyle>
        <color>ff0000ff</color>
        <width>4</width>
      </LineStyle>
    </Style>
    <Style id="greenLine">
      <LineStyle>
        <color>ff009900</color>
        <width>4</width>
      </LineStyle>
    </Style>
    <Style id="orangeLine">
      <LineStyle>
        <color>ff00ccff</color>
        <width>4</width>
      </LineStyle>
    </Style>
    <Style id="pinkLine">
      <LineStyle>
        <color>ffff33ff</color>
        <width>4</width>
      </LineStyle>
    </Style>
    <Style id="brownLine">
      <LineStyle>
        <color>ff66a1cc</color>
        <width>4</width>
      </LineStyle>
    </Style>
    <Style id="purpleLine">
      <LineStyle>
        <color>ffcc00cc</color>
        <width>4</width>
      </LineStyle>
    </Style>
    <Style id="yellowLine">
      <LineStyle>
        <color>ff61f2f2</color>
        <width>4</width>
      </LineStyle>
    </Style>

    <Placemark>
      <name>Blue Line</name>
      <styleUrl>#blueLine</styleUrl>
      <LineString>
        <altitudeMode>relative</altitudeMode>
        <coordinates>
-87.89289951324463,41.97881025520548,0
-87.89184808731079,41.97788506340239,0
-87.89150476455688,41.97762983571196,0
-87.8912901878357,41.97750222148314,0
-87.73756206035614,41.8521016001764,0
-87.73778736591339,41.85206164224564,0
-87.73803412914276,41.85206164224564,0
-87.74552285671234,41.85189381866398,0
-87.7565735578537,41.85182988575514,0
        </coordinates>
      </LineString>
    </Placemark>

    <Placemark>
      <name>Red Line</name>
      <styleUrl>#redLine</styleUrl>
      <LineString>
        <altitudeMode>relative</altitudeMode>
        <coordinates>
-87.67283499240875,42.019110918045044,0
-87.66907453536987,42.01585473134908,0
-87.66744375228882,42.014483688722116,0
-87.66716480255127,42.014228607763144,0
-87.626058,41.750851,0
-87.625870,41.736142,0
-87.625259,41.721877,0
        </coordinates>
      </LineString>
    </Placemark>

    <Placemark>
      <name>Green Line</name>
      <styleUrl>#greenLine</styleUrl>
      <LineString>
        <altitudeMode>relative</altitudeMode>
        <coordinates>
-87.8049498796463,41.8868887424469,0
-87.79437124729156,41.88703894615173,0
-87.78372824192047,41.88716769218445,0
-87.77429759502411,41.88731789588928,0
-87.75661647319794,41.88741445541382,0
-87.64607191085815,41.77918195724487,0
-87.64630794525146,41.77923560142517,0
-87.664416,41.778970,0
        </coordinates>
      </LineString>
    </Placemark>

    <Placemark>
      <name>Orange Line</name>
      <styleUrl>#orangeLine</styleUrl>
      <LineString>
        <altitudeMode>relative</altitudeMode>
        <coordinates>
-87.73805022239685,41.78673505783081,0
-87.73810386657715,41.79256081581116,0
-87.72440314292908,41.79991006851196,0
-87.71584153175354,41.80354714393616,0
-87.6268458366394,41.87411069869995,0
-87.62665271759033,41.86731934547424,0
        </coordinates>
      </LineString>
    </Placemark>

    <Placemark>
      <name>Pink Line</name>
      <styleUrl>#pinkLine</styleUrl>
      <LineString>
        <altitudeMode>relative</altitudeMode>
        <coordinates>
-87.6339054107666,41.88586950302124,0
-87.633890,41.883259,0
-87.633885,41.879289,0
-87.63370156288147,41.87709331512451,0
-87.63366937637329,41.876996755599976,0
-87.63359427452087,41.87693238258362,0
-87.63347625732422,41.87690019607544,0
-87.62633085250854,41.876975297927856,0
-87.73803412914276,41.85206164224564,0
-87.74552285671234,41.85189381866398,0
-87.7565735578537,41.85182988575514,0
        </coordinates>
      </LineString>
    </Placemark>

    <Placemark>
      <name>Brown Line</name>
      <styleUrl>#brownLine</styleUrl>
      <LineString>
        <altitudeMode>relative</altitudeMode>
        <coordinates>
-87.71307349205017,41.96800221934201,0
-87.71303057670593,41.96639082739174,0
-87.71301984786987,41.96627914525123,0
-87.63107299804688,41.885762214660645,0
-87.6339054107666,41.88586950302124,0
-87.634110,41.888634,0
        </coordinates>
      </LineString>
    </Placemark>

    <Placemark>
      <name>Purple Line</name>
      <styleUrl>#purpleLine</styleUrl>
      <LineString>
        <altitudeMode>relative</altitudeMode>
        <coordinates>
-87.69055902957916,42.072787284851074,0
-87.68584907054901,42.06420421600342,0
-87.633885,41.879289,0
-87.633890,41.883259,0
-87.6339054107666,41.88586950302124,0
-87.634110,41.888634,0
        </coordinates>
      </LineString>
    </Placemark>

    <Placemark>
      <name>Yellow Line</name>
      <styleUrl>#yellowLine</styleUrl>
      <LineString>
        <altitudeMode>relative</altitudeMode>
        <coordinates>
-87.75250,42.04049,0
-87.74726629257202,42.02620267868042,0
-87.74621486663818,42.0246148109436,0
-87.6747179031372,42.02038764953613,0
-87.67283499240875,42.019110918045044,0
        </coordinates>
      </LineString>
    </Placemark>

  </Document>
</kml>
时间: 2024-10-13 20:19:23

Google maps api demo的相关文章

Android Google Maps API 网络服务用于网络定位、计算路线、获取经纬度、获取详细地址等

---恢复内容开始--- extends:http://blog.csdn.net/h7870181/article/details/12505883 Google Maps API 网络服务 官网地址 : https://developers.google.com/maps/documentation/webservices/?hl=zh-cn 其实就是一些接口,供我们调用,如: 1.根据地址获取经纬度 http://maps.google.com/maps/api/geocode/json?

Google Maps API Web Services

原文:Google Maps API Web Services 摘自:https://developers.google.com/maps/documentation/webservices/ Google Maps API Web Services 本文将探讨 Google Maps API Web Services,这是一个为您的地图应用程序提供地理数据的 Google 服务的 HTTP 接口集合.本指南仅旨在介绍通用于所有不同服务的 Web 服务和托管信息.每个服务的单个文档位于以下位置:

Google Maps API V3 之绘图库 信息窗口

绘图库 本文档中的概念仅适用于 google.maps.drawing 库中提供的地图项.默认情况下,系统在加载 Maps JavaScript API 时不会加载该库,您必须使用 libraries 引导程序参数进行明确指定. http://maps.googleapis.com/maps/api/js?sensor=false&libraries=drawing DrawingManager 类提供了一个图形界面,以供用户在地图上绘制多边形.矩形.折线.圆形和标记.DrawingManage

Google Maps API V3 之 路线服务

概述 您可以使用 DirectionsService 对象计算路线(使用各种交通方式).此对象与 Google Maps API 路线服务进行通信,该服务会接收路线请求并返回计算的结果.您可以自行处理这些路线结果,也可以使用 DirectionsRenderer 对象呈现这些结果. 您可以通过文本字符串(例如,“伊利诺斯州芝加哥市”或“澳大利亚新南威尔士州达尔文市”)或 LatLng 值的形式来指定路线的起点和终点.路线服务可以使用一系列路标返回多段路线.路线可以显示为一条在地图上绘制路线的折线

Google Maps API V3 之 图层

图层概述 图层是地图上的对象,包含一个或多个单独项,但可作为一个整体进行操作.图层通常反映了您添加到地图上用于指定公共关联的对象集合.Maps API 会通过以下方法管理图层内对象的显示形式:将图层的组成项呈现在一个对象(通常为一个图块叠加层)中并根据地图视口的变化情况进行显示.图层还可以改变地图自身的展示图层,以符合图层样式的方式稍稍改变基本图块.请注意,系统将大部分图层设计为禁止通过其单个对象进行访问,而仅可将其作为一个整体来操作. 要在地图上添加图层,只需调用 setMap() 并向其传递

Google Maps API显示地图的小示例

来源:http://www.ido321.com/1089.html 效果(新版Firefox中测试): 代码: <!DOCTYPE> <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <title>Google Map</title> <script type="te

Google maps API

http://stackoverflow.com/questions/10736664/load-kml-file-into-google-maps-api http://wenku.baidu.com/link?url=r42agq4KFMc3kPfNrdT4mH0NLxquwtztujARlKhphNR35nKLGorOx2dYqliLQeGKefFr_X_cGi3kKiu2asrVmTBBsdqbvPvI0JeWi5fct2a http://www.cnblogs.com/fhmsha/a

Google Map API V3开发(2)

3 Google Map API 简介 Google 地图 API 免费提供给用户并且适用于所有网站.Google 地图 API 使您能够使用 JavaScript 将 Google地图嵌入自己的网页中.API 提供了大量实用工具用以处理地图(正如 http://ditu.google.com 网页上的地图),并通过各种服务向地图添加内容,从而使您能够在您的网站上创建功能强大的地图应用程序. 4 帮助资源 ?Google Maps JavaScript API v3 ?中文页面:https://

Google Map API V3开发(6) 代码

<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Google Maps API V3 Demo</title> <script type="text/javascript" src='http://maps.googleapis.com/maps/api/js?v=3&sensor=tru