• GOOGLE 地图,查询地名,移动标记,生成静态地图


    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <style>
    body
    { margin: 0; padding: 10px; }
    </style>
    <script src="http://maps.googleapis.com/maps/api/js?sensor=false&language=zh_CN"></script>
    <script>
    var map, geocoder,marker;
    function initialize() {
    var latlng = new google.maps.LatLng(29.56301,106.551557);
    var options = {
    zoom:
    11,
    center: latlng,
    disableDefaultUI:
    true,
    panControl:
    true,
    zoomControl:
    true,
    mapTypeControl:
    true,
    scaleControl:
    true,
    streetViewControl:
    false,
    overviewMapControl:
    true,
    mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map
    = new google.maps.Map(document.getElementById("map_canvas"), options);
    geocoder
    = new google.maps.Geocoder();

    marker
    = new google.maps.Marker({
    map: map,
    position: latlng,
    draggable:
    true
    });

    geocoder.geocode({latLng: latlng},
    function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
    if (results[3]) {
    document.getElementById(
    "map_address").value = results[3].formatted_address;
    }
    }
    });
    }
    function search() {
    if (!map) return;

    var address=document.getElementById("map_address").value;
    geocoder.geocode({address : address},
    function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
    //map.setZoom(11);
    map.setCenter(results[0].geometry.location);
    marker.setPosition(results[
    0].geometry.location);
    }
    else {
    alert(
    "没有找到: " + address);
    }
    });
    }

    function getbjd()
    {
    var center = map.getCenter().lat() + ',' + map.getCenter().lng(),
    zoom
    = map.getZoom(),
    maptype
    = map.getMapTypeId(),
    markers
    =marker.getPosition().lat() + ',' + marker.getPosition().lng();
    var url = 'http://maps.googleapis.com/maps/api/staticmap';
    url
    += '?center=' + encodeURIComponent(center);
    url
    += '&zoom=' + encodeURIComponent(zoom);
    url
    += '&size=600x400';
    url
    += '&maptype=' + encodeURIComponent(maptype);
    url
    += '&markers=' + encodeURIComponent(markers);
    url
    += '&language=zh_CN';
    url
    += '&sensor=false';

    document.getElementById(
    "imgurl").value=url;
    document.getElementById(
    "simg").src=url;
    }

    </script>
    </head>

    <body onload="initialize();">

    <div>地址 <input id="map_address" name="address" value="" style="200px;" />

    <input type="button" onclick="search()" name="searchBtn" value="搜索" />
    </div>
    <table width='100%'>
    <tr>
    <td width='600'><div id="map_canvas" style="600px; height:400px;"></div></td>
    <td><input type="button" onclick="getbjd()" name="getBtn" value="生成静态图" /></td>
    <td><img src="" width='600' height='400' id='simg' /></td>
    </tr>

    </table>

    <textarea id='imgurl' style='600px;height:50px;'></textarea>
    =
    </body>
    </html>
  • 相关阅读:
    Java_Habse_add
    Java_Habse_shell
    android Studio 出现:Unable to resolve dependency for ':app@debug/compileClasspath'
    微信小程序云函数中有以下未安装的依赖,如果未安装即全量上传
    Bittorrent Protocol Specification v1.0 中文
    BT客户端实现 Peer协议设计
    NGINX 配置 SSL 双向认证
    openssl、x509、crt、cer、key、csr、ssl、tls 这些都是什么鬼?
    ssl双向认证和单向认证原理
    网络服务器之HTTPS服务
  • 原文地址:https://www.cnblogs.com/Task/p/2333738.html
Copyright © 2020-2023  润新知