﻿<?xml version="1.0" encoding="utf-8"?>
<mapplet>
	<Property title="查看LML文件" description="查看LML地图标注数据，数据通过Mapplet的URL参数传递到Mapplet" author="lingtu" email="liaoqingkun@lingtu.com" screenshot="http://api.51ditu.com/special/bcase/images/shenyou.jpg" thumbnail="http://api.51ditu.com/special/bcase/images/step1.gif" site="http://www.51ditu.com">
		<Require feature="dynamic-height"/>
	</Property>
	<Content>
	<![CDATA[
		<DIV id="InputDiv" style="font-size:12px;">
			LML URL:
			<input type="text" id="lmlPath" size="10" style="font-size:12px;"/>
			<input type="button" value="加载" onclick="loadLml(document.getElementById('lmlPath').value)" style="font-size:12px;"/>
		</DIV>
		<DIV id="contentDiv"></DIV>
		<script language="javascript" src="http://api.51ditu.com/js/mapeditor.js" defer="true"></script>
		<script language="javascript">
			var map,viewer;
			function loadLml(path)
			{
				viewer.loadRemoteLmlFile(path);
			}
			function onLoad()
			{
				map=new LTMaps();
				viewer=new LTMapViewer({contentDiv:document.getElementById("contentDiv")});
				map.addControl(viewer);
				viewer.addEditor(new LTMarkerEditor());
				viewer.addEditor(new LTPolyLineEditor());
				viewer.addEditor(new LTFolderEditor());
				LTEvent.addListener(viewer,"loaded",onLmlLoaded);
				if(mapplet.getParam("url"))
				{
					loadLml(decodeURIComponent(mapplet.getParam("url")));
				}
			}
			function onLmlLoaded()
			{
				var bounds=viewer.getBounds();
				if(bounds.getXmin()>bounds.getXmax() || bounds.getYmin()>bounds.getYmax())
				{
					alert('该地图上没有任何元素');
					map.centerAndZoom("beijing",5);
				}
				else
				{
					map.centerAndZoom(bounds.getCenterPoint(),this.map.getBestZoom(bounds));
					document.getElementById("InputDiv").style.display="none";
				}
			}
			window.onload=onLoad;
		</script>
	]]>
	</Content>
</mapplet>