以下是一个网页,通过地图上的某个点的经纬度来得到地理信息,
现在我的需要将其做成一个函数,传入经度和纬度,然后请求google地址解析服务,返回地理信息
函数原形:
CString  byLoLnToMap(CString lo,CString ln)
{}
=======================================================================================================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Google Maps JavaScript API Example:  Reverse Geocoder</title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA" 
            type="text/javascript"></script>
    <script type="text/javascript">    var map;
    var geocoder;
    var address;    function initialize() {
      map = new GMap2(document.getElementById("map_canvas"));
      map.setCenter(new GLatLng(40.730885,-73.997383), 15);
      map.setUIToDefault();
      GEvent.addListener(map, "click", getAddress);
      geocoder = new GClientGeocoder();
    }
    
    function getAddress(overlay, latlng) {
      if (latlng != null) {
        address = latlng;
        geocoder.getLocations(latlng, showAddress);
      }
    }    function showAddress(response) {
      map.clearOverlays();
      if (!response || response.Status.code != 200) {
        alert("Status Code:" + response.Status.code);
      } else {
        place = response.Place[0];
        point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
        er = new GMarker(point);
        map.addOverlay(er);
        er.openInfoWindowHtml(
        '<b>orig latlng:</b>' + response.name + '<br/>' + 
        '<b>latlng:</b>' + place.Point.coordinates[1] + "," + place.Point.coordinates[0] + '<br>' +
        '<b>Status Code:</b>' + response.Status.code + '<br>' +
        '<b>Status Request:</b>' + response.Status.request + '<br>' +
        '<b>Address:</b>' + place.address + '<br>' +
        '<b>Accuracy:</b>' + place.AddressDetails.Accuracy + '<br>' +
        '<b>Country code:</b> ' + place.AddressDetails.Country.CountryNameCode);
      }
    }
    </script>
  </head>  <body onload="initialize()">
    <div id="map_canvas" style="width: 500px; height: 400px"></div>
  </body>
</html>
=============================================================================

解决方案 »

  1.   

    你这里有个问题,猜测可能是你的瓶颈就是vc怎么执行javascript...搜索一下mshtml http://topic.csdn.net/u/20091218/11/89f637fa-a8ed-4efe-adf4-3c97f8561828.html可以看看这上的代码
      

  2.   

    “你这里有个问题,猜测可能是你的瓶颈就是vc怎么执行javascript...”
    应该是可以的,浏览器都是用c++开发的,考虑用 浏览器控件, 
      

  3.   

    肯定是可以的额,我也做了个这个程序。vc可以很顺利的调用javascript,javascript也可以调用vc函数了,可是传递参数还不行了。
      

  4.   

    个人认为这样的应用应该是,能够处理google的地图GMap对象的vc函数
      

  5.   

    简单的介绍下浏览器的工作原理:
    1。用户输入url发送请求,发送http头到服务器,
    然后服务器根据浏览器的要求执行一个处理,处理之后的动态数据静态生成到页面中,
    将页面返回到浏览器,
    2。浏览器得到html文件,解析javascript脚本,并执行脚本,边解析文件边显示结果;
      

  6.   


    +1,
    弄个库,EXE加载此库,库再提供此接口。能用mfc的话,用CHtmlView做些封装快多了。
      

  7.   

    用 vc里面的 web浏览器控件里面的一个调用js函数的Calljavascript,好像是这个,具体函数的名字我忘记了,