MapGuide与Google Maps集成(Integrate Google Maps into MapGuide Enterprise Fusion viewer)

简介:


As you know, Google Maps is more and more popular around the world. Is it possible to integrate Google Maps into my MapGuide Enterprise Fusion viewer as base map? Yes, it is!

As MapGuide Fusion viewer uses a subset of OpenLayers, it allows us to access to the underlying OpenLayers API. In this article, we will show you how to integrate Google Maps into our existing Fusion Viewer template. Of cause, you can do that similarly to integrate Yahoo Maps or Virtual Earth Maps as well.

 

Firstly, we need to make a copy of our existing Fusion template, such as Slate.

Copy and rename C:\Program Files\Autodesk\MapGuideEnterprise2010\WebServerExtensions\www\fusion\templates\mapguide\slate as GoogleSlate at the same fold with slate.

And copy and rename C:\Program Files\Autodesk\MapGuideEnterprise2010\WebServerExtensions\www\fusion\templates\mapguide\slate.xml as GoogleSlate.xml at the same folder with slate.xml (Please note that the filename of xml should be same with the template folder).

 

Secondly, we will make some changes in the GoogleSlate.xml. Open it in notepad or any other text editor you like, change the lines like this:

ContractedBlock.gif Code

 

Now, we need to add Google Maps in to this new template. To do that, we need to apply a Google Map API key. The Google Maps API lets you embed Google Maps in your own web pages with JavaScript. A single Maps API key is valid for a single "directory" or domain. You must have a Google Account to get a Maps API key, and your API key will be connected to your Google Account. You can refer to http://code.google.com/apis/maps/ for more information. When you are done with that, you will get a JavaScript library like this:

< script src = ' http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxTS6gjckBmeABOGXIUiOiZObZESPg ' ></ script >  

 

Let's open the index.html in GoogleSlate folder using notepad, add the Google Maps API library before the fusion script library.

ContractedBlock.gif Code

We need to register a MAP_LOADED event for the map when fusion is initialized:

ContractedBlock.gif Code

Create the Map_LOADED event handler to the add Google Maps as base map:

ContractedBlock.gif Code

If you changed the preview.pgn and refresh in MapGuide Studio, you will find a new Fusion template(GoogleSlate) available now. If Studio is already running, the list of available templates can be refreshed by right-clicking in the display of templates, and selecting "Refresh".

 

OK, we are almost there. You can put a map into this new template and try. But before that, there is still a one more thing we should pay attention to. As the Google Maps use EPSG:3785 (Popular Visualisation CRS / Mercator) coordinate system, in order to make your map match with Google Maps perfectly, you should use EPSG:3785 in your map as well. You can change the WKT of coordinate system by editing the XML of MapDefiniation. The OpenSource tool Meastro can do that conveniently.

 

 

You can change the value of <CoordinateSystem> as below:

ContractedBlock.gif Code

 

Now, select the new template and set the map, and review, you should see the Google Maps is integrated into your map allocation as base map. Is it cool? Try it now J

 

作者: 峻祁连
邮箱:junqilian@163.com 
出处: http://junqilian.cnblogs.com 
转载请保留此信息。



本文转自峻祁连. Moving to Cloud/Mobile博客园博客,原文链接:http://www.cnblogs.com/junqilian/archive/2009/09/10/1554469.html ,如需转载请自行联系原作者
相关文章
|
4月前
|
JSON 定位技术 API
谷歌地图接口Google Maps APIs中地图样式设计配置调整与JSON或URL导出
谷歌地图接口Google Maps APIs中地图样式设计配置调整与JSON或URL导出
|
4月前
|
Java 数据安全/隐私保护
SpringBoot【集成Thumbnailator】Google开源图片工具缩放+区域裁剪+水印+旋转+保持比例等(保姆级教程含源代码)
SpringBoot【集成Thumbnailator】Google开源图片工具缩放+区域裁剪+水印+旋转+保持比例等(保姆级教程含源代码)
73 0
|
JavaScript 前端开发 定位技术
最佳网络地图服务对比分析:Google Maps 与 OpenStreetMap
最佳网络地图服务对比分析:Google Maps 与 OpenStreetMap
381 0
最佳网络地图服务对比分析:Google Maps 与 OpenStreetMap
|
JSON 小程序 定位技术
Google Maps APIs地图样式的设计与导出方法
本文介绍在谷歌地图API(Google Maps APIs)中,设计地图样式并将设计好的样式通过JSON或URL导出的方法~
214 1
Google Maps APIs地图样式的设计与导出方法
|
API
Google Guava之Maps&Lists&Sets
日常开发中,使用最多的就是集合了,所以避免不了对集合的各种操作,本篇文章来看一下,Guava中都有哪些常用的集合操作的API可以简化我们的代码。
194 0
Google Guava之Maps&Lists&Sets
|
编解码 定位技术
Planet比Google earth更好用的地图下载神器Basemaps Viewer不用写代码全球高清影像框选下载tif格式
Planet比Google earth更好用的地图下载神器Basemaps Viewer不用写代码全球高清影像框选下载tif格式
519 0
Planet比Google earth更好用的地图下载神器Basemaps Viewer不用写代码全球高清影像框选下载tif格式
|
存储 前端开发 JavaScript
Google Earth Engine(GEE)——Qgis-earthengine使用 Python API 集成 Google Earth Engine 和 QGIS
Google Earth Engine(GEE)——Qgis-earthengine使用 Python API 集成 Google Earth Engine 和 QGIS
432 0
Google Earth Engine(GEE)——Qgis-earthengine使用 Python API 集成 Google Earth Engine 和 QGIS
|
传感器 移动开发 JavaScript
html5指南 -- 7.geolocation结合google maps一例
  demo地址:http://www.mycookingroom.com/geo.html     今天我们将把html5的geolocation结合google maps开发一个小的应用。google maps的api地址:https://developers.google.com/maps/documentation/javascript/?hl=zh-CN。
880 0
|
Java API 定位技术
google地图密钥申请与将google地图集成到自己的程序中(附源代码)
开发google地图,很重要的一个类就是MpaView,MapView类是一个让你的应用可以和Google Maps融合到一起的类,就是说通过MapView你可以让你的应用来下载、显示、标记和控制Google Maps。
1108 0

热门文章

最新文章