当前位置: 代码迷 >> Web前端 >> am地图 使用及破解
  详细解决方案

am地图 使用及破解

热度:275   发布时间:2012-10-08 19:54:56.0
ammap 使用及破解
  公司最近的项目上需要一个能在地图上显示各个基地的功能,首先想到的是用类似google baidu的地图api的方案,被老总以不够炫为由给否了。
 
    以前在项目中用过amchart,记得有一个孪生兄弟 ammap。基于对amchart的良好印象,遂决定用ammap。

   以下是部分代码

 <script type="text/javascript">
			var w=$("#rbody").width();
			var so = new SWFObject("${pageContext.request.contextPath}/static/chart/ammap.swf", "ammap", w, "600", "8", "#e5f5fd");
				so.addVariable("path", "${pageContext.request.contextPath}/static/chart/");
				so.addVariable("settings_file", escape("${pageContext.request.contextPath}/static/chart/countries.xml"));
				so.addVariable("data_file", escape("${pageContext.request.contextPath}/plan/createamMapXml"));
				so.write("flashcontent"); 
</script>

关键读取数据是createamMapXml这个方法


String createamMapXml(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		SAXBuilder sb = new SAXBuilder();
		InputStream input = Thread.currentThread().getContextClassLoader()
				.getResourceAsStream("china.xml");
		Document doc = sb.build(input);
		String contextPath=request.getContextPath();
		Element map = doc.getRootElement();
		Element movies = new Element("movies");
		marketPriceService.createMap(contextPath, map, movies);
		String xmlStr = formatXml(doc);
//		System.out.println(xmlStr);
		response.setContentType("text/xml");
		return xmlStr;
}

public void createMap(String contextPath, Element map, Element movies) {
		List<Bases> list = basesService.getBasesByCurrentStateAndBases(0);
		Element areas=map.getChild("areas");
		List areaList=areas.getChildren("area");
		for (Iterator<Bases> iterator = list.iterator(); iterator.hasNext();) {
			Bases bases = (Bases) iterator.next();
//			System.out.println(bases.getRegion().getState());
			Element movie = new Element("movie");
			movie.setAttribute("title", bases.getName()==null?"": bases.getName());
			movie.setAttribute("file", "target");
			movie.setAttribute("color", "#FFBB77");
			movie.setAttribute("width", "10");
			movie.setAttribute("height", "10");
			
			movie.setAttribute("long", String.valueOf(bases.getLongitude()));
			movie.setAttribute("lat", String.valueOf(bases.getLatitude()));
			movie.setAttribute("url", 
					contextPath+ "/plan/planBaseQuery?baseId=" + bases.getId());
			movie.setAttribute("fixed_size", "true"); 
			movies.addContent(movie);
			for (Iterator iterator2 = areaList.iterator(); iterator2.hasNext();) {
				Element area = (Element) iterator2.next();
				String title=area.getAttribute("title").getValue();
				if(StringUtils.isNotBlank(title)&&bases.getRegion().getState().contains(area.getAttribute("title").getValue()))
					area.setAttribute("color","#55AA00");
			}
		}
		Element movie = new Element("movie");
		movie.setAttribute("title","北京");
		movie.setAttribute("file", "star.gif");
		movie.setAttribute("color", "#CC0000");
		movie.setAttribute("width", "15");
		movie.setAttribute("height", "15");
		movie.setAttribute("long", "116.235004");
		movie.setAttribute("lat", "40.4850468229644"); 
		movie.setAttribute("fixed_size", "true"); 
		movies.addContent(movie);
		map.addContent(movies);
	}

china.xml

<map map_file="china.swf" tl_long="73.620045" tl_lat="53.553745" br_long="134.768463" br_lat="18.168882" zoom="95%" zoom_x="3.72%" zoom_y="5%">
  <areas>
    <area mc_name="CN_34" title="安徽" zoom="466.1997%" zoom_x="-290.31%" zoom_y="-269.99%"/>
    <area mc_name="CN_11" title="北京" zoom="1339.0088%" zoom_x="-907.23%" zoom_y="-546.2%"/>
    <area mc_name="CN_50" title="重庆" zoom="661%" zoom_x="-321.46%" zoom_y="-426.93%"/>
    <area mc_name="CN_35" title="福建" zoom="570%" zoom_x="-371.74%" zoom_y="-422.11%"/>
    <area mc_name="CN_62" title="甘肃" zoom="328%" zoom_x="-99.85%" zoom_y="-126.55%"/>
    <area mc_name="CN_44" title="广东" zoom="661%" zoom_x="-387.57%" zoom_y="-541.67%"/>
    <area mc_name="CN_45" title="广西" zoom="431.9835%" zoom_x="-197.24%" zoom_y="-344.27%"/>
    <area mc_name="CN_52" title="贵州" zoom="661%" zoom_x="-308%" zoom_y="-483%"/>
    <area mc_name="CN_46" title="海南" zoom="1536%" zoom_x="-861.05%" zoom_y="-1463.21%"/>
    <area mc_name="CN_13" title="河北" zoom="661%" zoom_x="-420.56%" zoom_y="-224.5%"/>
    <area mc_name="CN_23" title="黑龙江" zoom="213.5378%" zoom_x="-138.47%" zoom_y="-0.13%"/>
    <area mc_name="CN_41" title="河南" zoom="596.3039%" zoom_x="-347.74%" zoom_y="-323.87%"/>
    <area mc_name="CN_91" title="香港" zoom="2000%" zoom_x="-1287.27%" zoom_y="-1771.35%"/>
    <area mc_name="CN_42" title="湖北" zoom="661%" zoom_x="-364.52%" zoom_y="-412.67%"/>
    <area mc_name="CN_43" title="湖南" zoom="561.0002%" zoom_x="-298.31%" zoom_y="-394.87%"/>
    <area mc_name="CN_15" title="内蒙古" zoom="169%" zoom_x="-57.44%" zoom_y="-12.88%"/>
    <area mc_name="CN_32" title="江苏" zoom="670%" zoom_x="-459.39%" zoom_y="-386.62%"/>
    <area mc_name="CN_36" title="江西" zoom="670%" zoom_x="-413.78%" zoom_y="-480.96%"/>
    <area mc_name="CN_22" title="吉林" zoom="470%" zoom_x="-352.64%" zoom_y="-114.03%"/>
    <area mc_name="CN_21" title="辽宁" zoom="565.7385%" zoom_x="-408.15%" zoom_y="-191.67%"/>
    <area mc_name="CN_92" title="澳门" zoom="661%" zoom_x="-428.53%" zoom_y="-246.17%"/>
    <area mc_name="CN_64" title="宁夏" zoom="757%" zoom_x="-357.92%" zoom_y="-338.77%"/>
    <area mc_name="CN_63" title="青海" zoom="461.4374%" zoom_x="-117.91%" zoom_y="-212.07%"/>
    <area mc_name="CN_61" title="陕西" zoom="461.4374%" zoom_x="-225.07%" zoom_y="-211.07%"/>
    <area mc_name="CN_37" title="山东" zoom="761.1344%" zoom_x="-508.99%" zoom_y="-367.03%"/>
    <area mc_name="CN_31" title="上海" zoom="2000%" zoom_x="-1525.75%" zoom_y="-1327.47%"/>
    <area mc_name="CN_14" title="山西"  zoom="462%" zoom_x="-245.21%" zoom_y="-195.04%"/>
    <area mc_name="CN_51" title="四川" zoom="364.3427%" zoom_x="-122.65%" zoom_y="-217.91%"/>
    <area mc_name="CN_12" title="天津" zoom="1683.576%" zoom_x="-1162.88%" zoom_y="-735.16%"/>
    <area mc_name="CN_54" title="西藏" zoom="245%" zoom_x="-11.59%" zoom_y="-124.76%"/>
    <area mc_name="CN_65" title="新疆" zoom="146.0037%" zoom_x="26.02%" zoom_y="-14.22%"/>
    <area mc_name="CN_53" title="云南" zoom="413.4326%" zoom_x="-140.39%" zoom_y="-306.15%"/>
    <area mc_name="CN_33" title="浙江" zoom="829.5282%" zoom_x="-588.25%" zoom_y="-568.46%"/>
    <area mc_name="TW" title="台湾" zoom="991.6529%" zoom_x="-719.43%" zoom_y="-819.77%"/>
    <area mc_name="borders" title="" color="#FFFFFF"/>
  </areas>
    <labels>
    <label long="84.947427" lat="42.4255522182285" text_size="12" color="#ADADAD" remain="true" >
      <text>新        疆</text>
    </label>
    <label long="93.664221" lat="35.9844221852234" text_size="12" color="#ADADAD" remain="true" >
      <text>青       海</text>
    </label>
    <label long="87.351449" lat="32.0448599653983" text_size="12" color="#ADADAD" remain="true" >
      <text>西       藏</text>
    </label>
    <label long="94.451443" lat="40.2213340878427" text_size="12" color="#ADADAD" remain="true" >
      <text>甘 肃</text>
    </label>
    <label long="102.503601" lat="40.7053671176742" text_size="12" color="#ADADAD" remain="true" >
      <text>内     蒙      古</text>
    </label>
    <label long="105.42382" lat="37.3192801788836" text_size="12" color="#ADADAD" remain="true" >
      <text>宁夏</text>
    </label>
    <label long="107.159457" lat="34.4963888002001" text_size="12" color="#ADADAD" remain="true" >
      <text>陕  西</text>
    </label>
    <label long="111.342981" lat="38.0728866718267" text_size="12" color="#ADADAD" remain="true" >
      <text>山 西</text>
    </label>
    <label long="114.2632" lat="38.6925749771918" text_size="12" color="#ADADAD" remain="true" >
      <text>河 北</text>
    </label>
    <label long="116.313726" lat="40.1379247682859" text_size="14" color="#ee0000" remain="true" >
      <text>北 京</text>
    </label>
    <label long="119.863724" lat="41.6601350846444" text_size="12" color="#ADADAD" remain="true" >
      <text>辽   宁</text>
    </label>
    <label long="123.81108" lat="44.3814182161181" text_size="12" color="#ADADAD" remain="true" >
      <text>吉  林</text>
    </label>
    <label long="124.838218" lat="47.4675971256227" text_size="12" color="#ADADAD" remain="true" >
      <text>黑  龙  江</text>
    </label>
    <label long="116.235004" lat="36.684938676849" text_size="12" color="#ADADAD" remain="true" >
      <text>山 东</text>
    </label>
    <label long="112.287647" lat="34.1014332163018" text_size="12" color="#ADADAD" remain="true" >
      <text>河 南</text>
    </label>
    <label long="110.394566" lat="31.6387174148497" text_size="12" color="#ADADAD" remain="true" >
      <text>湖 北</text>
    </label>
    <label long="106.289764" lat="30.0746786984768" text_size="12" color="#ADADAD" remain="true"  >
      <text>重 庆</text>
    </label>
    <label long="100.580529" lat="30.5783306607435" text_size="12" color="#ADADAD" remain="true" >
      <text>四   川</text>
    </label>
    <label long="99.111048" lat="24.8874581099438" text_size="12" color="#ADADAD" remain="true" >
      <text>云  南</text>
    </label>
    <label long="105.502542" lat="27.1538015125393" text_size="12" color="#ADADAD" remain="true" >
      <text>贵 州</text>
    </label>
    <label long="110.158399" lat="27.9248636108764" text_size="12" color="#ADADAD" remain="true" >
      <text>湖  南</text>
    </label>
    <label long="114.499367" lat="28.9016002459833" text_size="12" color="#ADADAD" remain="true" >
      <text>江 西</text>
    </label>
    <label long="116.156282" lat="31.6387174148497" text_size="12" color="#ADADAD" remain="true" >
      <text>安 徽</text>
    </label>
    <label long="118.049364" lat="33.9704099613927" text_size="12" color="#ADADAD" remain="true" >
      <text>江 苏</text>
    </label>
    <label long="121.524387" lat="31.1663917093303" text_size="12" color="#ADADAD" remain="true" >
      <text>上 海</text>
    </label> 
    <label long="118.68289" lat="29.3160185360148" text_size="12" color="#ADADAD" remain="true" >
      <text>浙 江</text>
    </label>
    <label long="117.104697" lat="26.4448121027352" text_size="12" color="#ADADAD" remain="true" >
      <text>福 建</text>
    </label>
    <label long="106.844569" lat="24.2987022240325" text_size="12" color="#ADADAD" remain="true" >
      <text>广 西</text>
    </label>
    <label long="112.36637" lat="23.7175422550551" text_size="12" color="#ADADAD" remain="true" >
      <text>广 东</text>
    </label>
    <label long="109.052539" lat="19.2954337299303" text_size="12" color="#ADADAD" remain="true" >
      <text>海 南</text>
    </label>
    <label long="120.418528" lat="23.8622173402318" text_size="12" color="#ADADAD" remain="true" >
      <text>台 湾</text>
    </label>
    <label long="117.18342" lat="39.0004249712802" text_size="12" color="#ADADAD" remain="true" >
      <text>天 津</text>
    </label>
  </labels>
  
   
</map>
到这里功能基本完成。。。

由于ammap和amchart一样是
This  software is free under a linkware license
存在一个ammap的logo链接

网上找了一下破解方法。。竟然没有现成的。只好自己动手 反编译amamp.swf


找到一个方法
function checkKey(serial)
{
    serial = com.ammap.Utils.stripSymbols(serial, " ");
    serial = com.ammap.Utils.stripSymbols(serial, "\n");
    serial = com.ammap.Utils.stripSymbols(serial, "\r");
    serial = com.ammap.Utils.stripSymbols(serial, "\r\n");
    arr = serial.split("-");
    if ((Number(arr[2]) + Number(arr[3]) == 8501 || Number(arr[2]) + Number(arr[3]) == 8801 || Number(arr[2]) + Number(arr[3]) == 8941) 
    && Number(arr[2].substr(1, 1)) - Number(arr[3].substr(2, 1)) == 5 
    || _url.split("/")[2].substr(-9) == "ammap.com")
    {
    }
    else
    {
        attachMovie("copyright_mc", "copyright_mc", 10001);
    } // end else if
} // End of the function

及这句话
if (key == undefined)
{
    key_loader.loadVars(path + "ammap_key.txt", this, "checkKey", false, "checkKey");
}


这也太容易破解了
在ammap所处的文件夹中新建一个ammap_key.txt文件
文件内容为
破-解-4960-3541-中国-lele

到此 大功告成!~~~
  相关解决方案