郭宇翔的博客
编程开发
说点编程开发的~
天地图GeoGlobe创建地图标记Marker
四 3rd
上一次我们已经在《天地图GeoGlobe开发入门》中利用GeoGlobe二维地图API创建了一个map对象,在div中显示出以嘉应学院为中心点的640*480像素大小的卫星地图,现在我们要在地图上添加地图标记,也就是Marker,用来标记出我们刚落成的“活活艺术教育中心”的位置所在。
实现也是比较简单的,我们通过实例化GeoSurf.LonLat和GeoSurf.Icon两个类,再在地图上创建一个特殊的层叫做GeoSurf.Layer最后实例化GeoSurf.Marker,最终创建一个地图标记Marker(GeoGlobe地标)。
源代码如下:
天地图GeoGlobe开发入门
四 2nd
现在我们以一个最简单的示例来帮助您快速对GeoGlobe二维地图API开发有一个全面的了解,并且有一个直观感性的认识。
下面的代码是在一个普通的HTML页面里加入一个以嘉应学院为中心点的640*480像素大小的卫星地图。
<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>天地图GeoGlobe开发入门DEMO</title>
<script src="http://www.tianditu.com/guide/lib/GeoSurfJSAPI.js"
type="text/javascript"></script>
<script src="http://www.tianditu.com/guide/2d_samples/sampleCfg.js"
type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
var map = new GeoSurf.PortalMap("frist_map");
map.loadLayerGroup(imageGroup);
map.setCenter(new GeoSurf.LonLat(116.12371, 24.33058), 14);
}
</script>
</head>
<body onload="initialize()" align=center>
<h1 style="marging:0 auto">天地图GeoGlobe开发入门DEMO---Yourtion.com</h1>
<div id="frist_map" style="width: 640px; height: 480px ; marging:0 auto"></div>
</body>
</html>
您查看此示例的实际效果:点击这里看Demo
用PHP输出转义JavaScript代码
四 1st
最近在做天地图是GIS集成··要输出HTML到JavaScript里面··涉及到代码转义什么的比较麻烦··所以写个PHP的function
分享一下:
function jsformat($str)
{
$str = trim($str);
$str = str_replace('\\s\\s', '\\s', $str);
$str = str_replace(chr(10), '', $str);
$str = str_replace(chr(13), '', $str);
$str = str_replace(' ', '', $str);
$str = str_replace('\\', '\\\\', $str);
$str = str_replace('"', '\\"', $str);
$str = str_replace('\\\'', '\\\\\'', $str);
$str = str_replace("'", "\'", $str);
return $str;
}
使用就不用说了··就是直接调用jsformat($str)
新浪微博API使用OAuth认证发布微博实例
三 23rd
继续前面的文章《新浪微博OAuth认证详解及验证数据储存》,现在我们就使用它来发布微博。
我们已经将用户新浪微博的oauth_token和oauth_secret保存到
$_SESSION['oauth_token']=$result['oauth_token'];
$_SESSION['oauth_secret']=$result['oauth_secret'];
Delphi调用Cmd并取得输出字符
三 20th
最近想做个调用CMD命令并取得结果的程序··找了一下··共享代码
procedure CheckResult(b: Boolean);
begin
if not b then
raise Exception.Create(SysErrorMessage(GetLastError));
end;
function RunDOS(const CommandLine: string): string;
var
HRead, HWrite: THandle;
StartInfo: TStartupInfo;
ProceInfo: TProcessInformation;
b: Boolean;
sa: TSecurityAttributes;
inS: THandleStream;
sRet: TStrings;
begin
Result := '';
FillChar(sa, sizeof(sa), 0);
//设置允许继承,否则在NT和2000下无法取得输出结果
sa.nLength := sizeof(sa);
sa.bInheritHandle := True;
sa.lpSecurityDescriptor := nil;
b := CreatePipe(HRead, HWrite, @sa, 0);
CheckResult(b);
FillChar(StartInfo, SizeOf(StartInfo), 0);
StartInfo.cb := SizeOf(StartInfo);
StartInfo.wShowWindow := SW_HIDE;
//使用指定的句柄作为标准输入输出的文件句柄,使用指定的显示方式
StartInfo.dwFlags := STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW;
StartInfo.hStdError := HWrite;
StartInfo.hStdInput := GetStdHandle(STD_INPUT_HANDLE); //HRead;
StartInfo.hStdOutput := HWrite;
b := CreateProcess(nil, //lpApplicationName: PChar
PChar(CommandLine), //lpCommandLine: PChar
nil, //lpProcessAttributes: PSecurityAttributes
nil, //lpThreadAttributes: PSecurityAttributes
True, //bInheritHandles: BOOL
CREATE_NEW_CONSOLE,
nil,
nil,
StartInfo,
ProceInfo);
CheckResult(b);
WaitForSingleObject(ProceInfo.hProcess, INFINITE);
inS := THandleStream.Create(HRead);
if inS.Size > 0 then
begin
sRet := TStringList.Create;
sRet.LoadFromStream(inS);
Result := sRet.Text;
sRet.Free;
end;
inS.Free;
CloseHandle(HRead);
CloseHandle(HWrite);
end;
使用方法也很简单···就是调用Function;
PHP开发者常犯的10个MySQL错误
三 18th
数据库是WEB大多数应用开发的基础。如果你是用PHP,那么大多数据库用的是MYSQL也是LAMP架构的重要部分。
PHP看起来很简单,一个初学者也可以几个小时内就能开始写函数了。但是建立一个稳定、可靠的数据库确需要时间和经验。下面就是一些这样的经验,不仅仅是MYSQL,其他数据库也一样可以参考。
1、使用MyISAM而不是InnoDB

最新评论