Calendar of Development

come on

  博客园 :: 首页 :: 新随笔 ::  ::  :: 管理 ::
  17 随笔 :: 2 文章 :: 35 评论 :: 2 引用

2007年1月25日 #


使用Type
.GetType(typeName)取另一个程序集的类时,只写命名空间和类名是不够的,必须指定Version,Culture, PublicKeyToken。

posted @ 2007-01-25 23:28 Calendar 阅读(82) | 评论 (0)编辑

2006年8月1日 #

GM的Hybrid原来是先显示Satellite,再叠加显示Map,把#EDEAE2这种颜色从Map图里设为透明色.
posted @ 2006-08-01 12:32 Calendar 阅读(98) | 评论 (1)编辑

2006年7月26日 #

MapPoint中常规方法插入Pushpin是:
MapPoint.Pushpin pii = map.AddPushpin(loc, "name1");
if(balloonState == 0)
 pii.BalloonState = GeoBalloonState.geoDisplayBalloon;
else if(balloonState == 1)
 pii.BalloonState = GeoBalloonState.geoDisplayName;
else
 pii.BalloonState = GeoBalloonState.geoDisplayNone;
pii.Symbol = symbol;
pii.Highlight = highLight;
pii.Note = "info1";
但这种方法地插入大量标记时速度非常慢,在4000个时大约需要9分钟。
机器配置是Pentium(R) D CPU 2.80GHz, 1.00GB内存。

在微软MapPoint论坛提问,回答说用VC写一个插件来批量插入Pushpin,可以避免Com/Interop的包装时间损耗,速度会快一些。
但那样的话,客户端布置麻烦。
因此,我试着用以下方式来提速。
如果不要求加亮或BalloonState,则速度更快,在5秒钟左右。

从数据库中读取数据并生成如下格式字符串,
其中, Name为pushpin的名称, info为提示字段, Latitude和Longitude为点的经纬度坐标

Name    Info    Latitude    Longitude
name1   info1    39.9456    75.0861
nam2     info2    39.9625    75.0875

再写一个函数实现导入pushpin功能, 并可以设定pushpin的符号, 是否加亮, 提示状态BalloonState.

protected bool ImportData(string content, int balloonState, bool highLight, short symbol)
{

    
construct the fields array

    
write temp file

    
import data and set pushpin features

}

posted @ 2006-07-26 14:18 Calendar 阅读(266) | 评论 (0)编辑

2006年7月4日 #

从google maps的脚本里扒了段代码,没准啥时会用上。大家一块看看是怎么算的。

private const double EARTH_RADIUS = 6378.137;
private static double rad(double d)
{
   return d * Math.PI / 180.0;
}

public static double GetDistance(double lat1, double lng1, double lat2, double lng2)
{
   double radLat1 = rad(lat1);
   double radLat2 = rad(lat2);
   double a = radLat1 - radLat2;
   double b = rad(lng1) - rad(lng2);
   double s = 2 * Math.Asin(Math.Sqrt(Math.Pow(Math.Sin(a/2),2) +
    Math.Cos(radLat1)*Math.Cos(radLat2)*Math.Pow(Math.Sin(b/2),2)));
   s = s * EARTH_RADIUS;
   s = Math.Round(s * 10000) / 10000;
   return s;
}

posted @ 2006-07-04 20:14 Calendar 阅读(7895) | 评论 (12)编辑

刚地震了一次,比较小型,公司的招牌晃了几下
posted @ 2006-07-04 11:59 Calendar 阅读(65) | 评论 (0)编辑

界面就是漂亮,支持Tab栏浏览,这样我的Mathon基本上可以退休了。没找到设定双击Tab栏即关闭的选项。
要的就是英文版的效果,这样上google论坛就可以看英文界面,不用老在中文海洋里晃悠了。
窗口标题栏变成了 Windows Internet Explorer,而不是以前的 Microsoft Internet Explorer。是微软的‘野心’?
往文本框中粘贴文本也变得有安全限制了,可以控制是否允许访问剪贴板内容。
安全性肯定是比以前强,苦了原来的javascript程序,要适应IE 7.0就得进行重新审查。

posted @ 2006-07-04 11:47 Calendar 阅读(328) | 评论 (10)编辑

2006年6月13日 #

最新增加了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="width: 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);

};

 

 

 

posted @ 2006-06-13 11:48 Calendar 阅读(1242) | 评论 (2)编辑

2006年4月27日 #


posted @ 2006-04-27 22:30 Calendar 阅读(130) | 评论 (0)编辑

google maps里最重要的对象应该算是GMapsApplication了,它的定义用到了javascript面向对象设计方法。

var a=z.prototype;
W("GMapsApplication",z);
P(z,"getMap",a.N);

function W(a,b){window[a]=b}
function P(a,b,c){a.prototype[b]=c}
z.prototype.N=function(){return this.a}

W函数把对象放在window属性里,可以为一个对象定义一个名称;
P函数则通过ptototype给对象增加方法别名。

有了这些,就可以用
var a = new GMapsApplication(e("map"));
像实例化一个javascript内置对象一样来实例化GMapsApplication了。
用起来还真方便。感觉把c#编程和脚本编程给拉近了一大截。
自己也写了个测试用例:

<script>
window[
"Hello"= aa;
function aa()
{
    
this.x = 5;
    
this.y = 6;
    
this.test = function(a)
    
{
        alert(a 
+ "," + this.x + "," + this.y);
    }

}


var xx = new Hello();
xx.test(
"bb");
</script>
posted @ 2006-04-27 21:15 Calendar 阅读(579) | 评论 (1)编辑

通过url跟踪,可以方便地取得google maps普通地图的图片url,如:
GET /mt?n=404&v=w2.10&x=3&y=6&zoom=13 HTTP/1.1
而对卫星地图图片的url像:
GET /kh?n=404&v=5&t=tqtsq HTTP/1.1
就不知它的t参数含义了。
今天看了看地图的.js文件,找到了如下代码,可以计算这个参数,也就可以动态构造出相应的url去批量下载卫星地图了。
代码如下:

<script>

function MapObj()
{
    
this.x;
    
this.y;
}


function test()
{
    
var o = new MapObj();
    
var ss = document.all("txtPos").value.split(",");
    o.x 
= ss[0];
    o.y 
= ss[1];
    
var zoom = parseInt(document.all("txtFactor").value);
    
var ret = cal(o, 17 - zoom);
    document.all(
"txtMess").value = ret;
}

function cal(a,b)
{
    
var c=Math.pow(2,b);//比例参数, 地图宽度图片数量
    var d=a.x;//a is the map object
    var e=a.y;
    
var f="t";
    
/*
    zoom = 13; b = 4; c = 2^4 = 16;
    
*/

    
for(var g=0;g<b;g++)//
    {
        c
=c/2;        // c / 2
        if(e<c)        //a.y < c
        {
            
if(d<c)//a.x < c
            {
                f
+="q"
            }

            
else//a.x >= c
            {
                f
+="r";
                d
-=//a.x = a.x - c
            }

        }

        
else//a.y >= c
        {
            
if(d<c)//a.x < c
            {
                f
+="t";
                e
-=//a.y = a.y - c
            }

            
else//a.x >= c
            {
                f
+="s";
                d
-=c;  //a.x = a.x - c
                e-=c   //a.y = a.y - c
            }

        }

    }

    
return "t=" + f;
    
//var h=(a.x+a.y)%this.wa.length;//
    //return this.wa[h]+"t="+f
}

</script>
(x,y)
<input type=text id="txtPos" value="3,7"><br>
zoom:
<input type=text id="txtFactor" value="13">
<input type=button value="check" onclick="test()">

<br>
   
<input type=text id="txtMess">

posted @ 2006-04-27 20:47 Calendar 阅读(1561) | 评论 (5)编辑