• google maps可以支持地理信息查询了(附上功能介绍)


    最新增加了GClientGeocoder类, google总算是推出了地理信息查询功能!!
    查询速度还比较快, 但好像只能比较好地搜索英文地址,
    对"Beijing", "北京"这样的词则提示搜不到结果.
    示例如下:

    var geocoder = new GClientGeocoder();
    function showAddress()
    {
     var address = document.getElementById("txtAddress").value;
     if(geocoder == null)
      return;
     
     geocoder.getLatLng(
      address,
      function(point)
      {
       if(point == null)
       {
        alert("no result!");
        return;
       }
       document.getElementById("mess").innerHTML = point.toString();
       map.setCenter(point, 14);
       var marker = new GMarker(point);
       map.addOverlay(marker);
       marker.openInfoWindowHtml(address);
      }
     );
    }

    function showAddress2()
    {
     var address = document.getElementById("txtAddress").value;
     if(geocoder == null)
      return;
     
     geocoder.getLocations(
      address,
      function(response)
      {
       if(!response || response.Status.code != 200)
       {
        alert("Sorry, we were unable to geocode that address!");
        return;
       }
       place = response.Placemark[0];
       point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
      
       map.setCenter(point, 14);
       var html = place.address + "<br>"
        + "<b>Country code:</b>" + place.AddressDetails.Country.CountryNameCode;
       var marker = new GMarker(point);
       marker.html = html;
       map.addOverlay(marker);
      
       marker.openInfoWindowHtml(html);
      }
     );
    }


    google maps api example
    http://www.google.com/apis/maps/documentation/

    google maps api reference
    http://www.google.com/apis/maps/documentation/reference.html

    研究google maps的站点
    http://www.mapki.com


    犯罪地图的一些站点:
    http://www.mapki.com/wiki/Map_Projects:Crime_Watchers

    对google maps进行控制的好例子:
    http://www.mapmap.org/googlemaps/examples.html

    只需要申请一个google maps的api的key值,并且有一个互联网的站点或本机有web服务器(localhost), 就可以进行maps的二次开发.
    在要显示地图的页面中加入脚本引用:
    <script src="http://maps.google.com/maps?file=api&v=2.x&key=abcd-keyvalue"
          type="text/javascript"></script>
    再加一个显示地图的div:
    <div id="map" style=" 800px; height: 600px"></div>

    就可以用脚本控制显示地图, 可以给地图加标注,加提示窗口,也可以调用GDownloadUrl下载文件,用GXml加载xml文本

    地图初始化为
    var map = new GMap2(document.getElementById("map"));
    加入地图缩放为GLaerMapControl或GSmallMapControl, GSmallZoomControl类
    加入地图图层控制为: GMapTypeControl
    加入比例尺显示为: GScaleControl
    加入缩略图显示为: GOverviewMapControl

    为map加事件为:
    GEvent.addListener(map, "moveend", function(){});

    //设置map的中心点和比例大小
    map.setCenter(new GLatLng(xxx,xxx), scale);

    //可以设置map的类型为某种图
    map.setMapType(G_SATELLITE_MAP | G_NORMAL_MAP | G_HYBRID_MAP  G_DEFAULT_MAP_TYPES );
    map.setMapType(map.getMapTypes()[2]);

    //加入map object时,可以指定显示的方位
    map.addControl(xx, new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(20,20));

    map.draggingEnabled()//是否允许拖动
    map.disableDargging()不许拖
    map.enableDragging()可以拖


    map.openInfoWindow(point, "");
    marker.openInfowindowHtml("");

    marker可以设定一些自定义属性,方便扩展很多内容.

    使用GXmlHttp的例子
    var request = GXmlHttp.create();
    request.open("GET", "data.xml?rnd=" + Math.random(), true);
    request.onreadystatechange = fucntion(){
    if(request.readyState == 4)
    {
    var xmlDoc = request.responseXML;
    var markers = xmlDoc.documentElement.getElementsByTagName("marker");
    ...
    }
    request.send(null);

    };

  • 相关阅读:
    C#的注释
    为知笔记发布到博客,css设置
    eclipse创建springboot项目的三种方法
    创建maven父项目以及子项目
    C# 快捷键(总结)
    idea 项目转 eclipse项目
    freemarker常见语法大全
    Spring Boot Freemarker特别篇之contextPath【从零开始学Spring Boot
    Spring mvc请求处理流程详解(一)之视图解析
    React+SpringBoot项目部署
  • 原文地址:https://www.cnblogs.com/panyee/p/424667.html
Copyright © 2020-2023  润新知