码迷,mamicode.com
首页 > 其他好文 > 详细

离线谷歌地图的开发笔记(一)

时间:2016-05-13 14:13:36      阅读:233      评论:0      收藏:0      [点我收藏+]

标签:

      最近做一个项目,用到离线谷歌地图的开发, 而现在谷歌地图在中国的发展不是很完美,导致项目的定项迟迟不能决定。

后来使用了一个地图插件mymapw.ocx,完美地解决了Winform窗体里非要加载webbrowse写JScript的弊端。

     目前,项目已经实施,特将里面的地图开发部分概要摘录下来,供大家参考:

技术分享

1.1 加载Mymap.ocx 地图控件到c#的窗体上

技术分享

二、先增加地图的基本功能操作: 放大、缩小、移动、测量距离、测量面积

 

增加放大、缩小、移动地图的代码

private void tsbMax_Click(object sender, EventArgs e)
{
  MyMap1.SetMapOperateMode(30);//放大
}
private void tsbMin_Click(object sender, EventArgs e)
{
  MyMap1.SetMapOperateMode(20);//缩小
}
private void tsbMove_Click(object sender, EventArgs e)
{
  MyMap1.SetMapOperateMode(40);//移动
}
 
技术分享
 
1.3 增加测量距离的代码
private void tsbDistance_Click(object sender, EventArgs e)
{
  MyMap1.SetMapOperateMode(50);//测量距离
}
技术分享
 增加测量面积的代码
private void tsbArea_Click(object sender, EventArgs e)
{
  MyMap1.SetMapOperateMode(90);//测量面积
}
技术分享
 
保存或修改标注点
private void btnPointSave_Click(object sender, EventArgs e)
{
  string strResult = null;
  string strPoiName = txtPoiName.Text;//名称
  string strLongitude = txtJD.Text;   //经度
  string strLatitude = txtWD.Text;    //纬度
  string strCity = ComboCity.Text;    //所属城市
  string strMinScale = cmbMin.Text;   //最小显示级别
  string strMaxScale = cmbMax.Text;   //最大显示级别
  string strFontName = ComboFont.Text;      //宋体
  string strFontSize = ComboFontSize.Text ; //字体大小
  string strFrontColor = m_Color.ToString();//字体颜色
  string strBmpFileName = "3.bmp";          //标记图标所属的文件名
  string strBmpIndex = txtBMPindex.Text;    //在图标文件里的索引
  string strObjectID = txtInfo.Text;        //气泡里显示的文字
  string strID = "";
  int nID = 0;
  if( m_PointADDorEDITtype == 1)
  {//增加新标注
      m_PointAddID++;
      nID = m_PointAddID;
      strID = nID.ToString();
      strResult = strResult + strID + "," + strPoiName + "," + strCity + "," + strFontName + "," + strFontSize + ","
          + strFrontColor + "," + strMinScale + "," + strMaxScale + "," + strBmpFileName + "," + strBmpIndex + ","
          + strLongitude + "," + strLatitude + "," + strObjectID + "," + ";";
  }
  else if(m_PointADDorEDITtype == 2)
  {//修改标注
       nID = m_PointEditID;
      strID = nID.ToString();
      strResult = strResult + strID + "," + strPoiName + "," + strCity + "," + strFontName + "," + strFontSize + ","
          + strFrontColor + "," + strMinScale + "," + strMaxScale + "," + strBmpFileName + "," + strBmpIndex + ","
          + strLongitude + "," + strLatitude + "," + strObjectID + "," + ";";
  }

 

  //‘‘标准的‘‘{"116,lim,青岛市,宋体,12,0,0,500,2.bmp,4,41896957,13454163,,;"}
  MyMap1.AddMyPoi(nID, strResult);
  MyMap1.DrawMap();
}
技术分享
 
在标注点的单击触发事件OnSelectPoi函数里处理自己想要做的事情(例如单击后弹出一个窗体,显示该标注点的一些信息)
private void MyMap1_OnSelectPoi(object sender, AxMYMAPLib._DMyMapEvents_OnSelectPoiEvent e)
{
  int nID = e.nID;
  if(!m_bEditPointState)
  {
    FrmPic form = new FrmPic(nID);
    form.ShowDialog();
    MyMap1.SetMapOperateMode(40);// ‘‘‘运动状态
  }
}技术分享
 
另外,还有添加道路、透明圆形、透明多边形、透明矩形、箭头等函数, 第一次发表文章,先写这么多吧,留着以后再整理。
技术分享
 
 

离线谷歌地图的开发笔记(一)

标签:

原文地址:http://www.cnblogs.com/mymapw/p/5487803.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!