MapGuide Open Source 中关于map.create() 和 map.open() 的用法
关于map.create() 和 map.open()
(一)
MgMap在创建时,利用map definition中的数据初始化。MgMap对象可能有变化(内存中的对象),但map definition 不会变(保存在repository中的一个xml文件)
When the MgMap object is created, it is initialized with data from the map
definition. As a user interacts with the map, the MgMap may change, but the
map definition does not.
Map对象保存在session repository(服务器内存)中,所以可以被所有的页面访问到。你不能把map对象保存到library repository(服务器硬盘的文件)中。由浏览器负责map对象的创建,在地图浏览器第一次被加载时,会自动在session repository中创建map对象。Map的名字就是从definition中读出来的。
The map is saved in the session repository so it is available to all pages in the
same session. You cannot save a map in the library repository.
Map creation is handled by the Viewers. When a Viewer first loads, it creates
a map in the session repository. The map name is taken from the map
definition name. For example, if a web layout references a map definition
named Sheboygan.MapDefinition, then the Viewer will create a map named
Sheboygan.Map.
(二)
但是如果你的应用程序不使用地图浏览器(这种情况还比较少,就是光调用MapGuide的地图服务,而不显示,可能是用其他的第三方的东西显示地图。我们现在经常用到的都不属于这中情况,而大多数都是上面的第一种情形。)这时候就需要自己创建map对象并自行保存到repository中。
If your application does not use a Viewer, you can create the map and store
it in the repository yourself. To do this, your page must
■ Create an MgMap object.(创建MgMap对象)
■ Initialize the MgMap object from a map definition.(从map definition中初始化MgMap对象)
■ Assign a name to the MgMap object.(赋予一个名字)
■ Save the map in the session repository.(保存到repository中)
For example, the following section of code creates an MgMap object named Sheboygan.Map, based on Sheboygan.MapDefinition.
下面就是一个自行创建map对象的例子代码,php的,其他语言也都类似:
$mapDefId = new MgResourceIdentifier(
"Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
$map = new MgMap();
$mapName = $mapDefId->GetName();
$map->Create($resourceService, $mapDefId, $mapName);
$mapId = new MgResourceIdentifier(
"SessionsessionId//$mapName." . MgResourceType::Map);
$map->Save($resourceService, $mapId);
(一)
MgMap在创建时,利用map definition中的数据初始化。MgMap对象可能有变化(内存中的对象),但map definition 不会变(保存在repository中的一个xml文件)
When the MgMap object is created, it is initialized with data from the map
definition. As a user interacts with the map, the MgMap may change, but the
map definition does not.
Map对象保存在session repository(服务器内存)中,所以可以被所有的页面访问到。你不能把map对象保存到library repository(服务器硬盘的文件)中。由浏览器负责map对象的创建,在地图浏览器第一次被加载时,会自动在session repository中创建map对象。Map的名字就是从definition中读出来的。
The map is saved in the session repository so it is available to all pages in the
same session. You cannot save a map in the library repository.
Map creation is handled by the Viewers. When a Viewer first loads, it creates
a map in the session repository. The map name is taken from the map
definition name. For example, if a web layout references a map definition
named Sheboygan.MapDefinition, then the Viewer will create a map named
Sheboygan.Map.
(二)
但是如果你的应用程序不使用地图浏览器(这种情况还比较少,就是光调用MapGuide的地图服务,而不显示,可能是用其他的第三方的东西显示地图。我们现在经常用到的都不属于这中情况,而大多数都是上面的第一种情形。)这时候就需要自己创建map对象并自行保存到repository中。
If your application does not use a Viewer, you can create the map and store
it in the repository yourself. To do this, your page must
■ Create an MgMap object.(创建MgMap对象)
■ Initialize the MgMap object from a map definition.(从map definition中初始化MgMap对象)
■ Assign a name to the MgMap object.(赋予一个名字)
■ Save the map in the session repository.(保存到repository中)
For example, the following section of code creates an MgMap object named Sheboygan.Map, based on Sheboygan.MapDefinition.
下面就是一个自行创建map对象的例子代码,php的,其他语言也都类似:
$mapDefId = new MgResourceIdentifier(
"Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
$map = new MgMap();
$mapName = $mapDefId->GetName();
$map->Create($resourceService, $mapDefId, $mapName);
$mapId = new MgResourceIdentifier(
"SessionsessionId//$mapName." . MgResourceType::Map);
$map->Save($resourceService, $mapId);
更多MapGuide相关信息可以参考