Tolong pilih kategori sesuai, jenis posting (diskusi atau bukan) dan sertakan tag/topik yang sesuai seperti komputer, java, php, mysql, dll. Promosi atau posting tidak pada tempatnya akan kami hapus!
- Bagi Anda yang ingin mendaftar, baca link berikut:
http://diskusiweb.com/discussion/50491/how-to-registrasi-diskusiweb-com-baca-ini-terlebih-dahulu
- Cara menyisipkan kode program supaya tampil rapi dan terformat dengan baik di diskusiweb.com: http://www.diskusiweb.com/discussion/50415/cara-menyisipkan-kode-program-di-diskusiweb-com
- Cara posting gambar/image di post Anda: http://www.diskusiweb.com/discussion/47345/cara-menyisipkan-menyertakan-image-pada-posting/p1

koordinat di gambar animasi gif

pagi master sekalian...
saya ingin tanya neh ttg memasukkan koordinat di peta.gif yang saya buat, tapi begitu di jalankan peta kelap kelipnya nggak jalan ... mohon bantuannya master sekalian

berikut prog yang telah saya coba:

index.php<div class='geshi_syntax'><table><tr><td><div class='code'><pre class="php"> 
<span class="kw2"><?php</span>
 
<span class="sy0"><</span>html<span class="sy0">></span>
<span class="sy0"><</span>head<span class="sy0">></span>
<span class="sy0"><</span>title<span class="sy0">></span>Membuat GIS <span class="sy0"></</span>title<span class="sy0">></span>
<span class="kw2"><script language</span><span class="sy0">=</span><span class="st_h">'JavaScript'</span><span class="sy0">></span>
<span class="kw2">var</span> ajaxRequest<span class="sy0">;</span>
 
<span class="kw2">function</span> getAjax<span class="br0">(</span><span class="br0">)</span> <span class="co1">//fungsi untuk mengecek apakah browser mendukung AJAX</span>
<span class="br0">{</span>
try
<span class="br0">{</span>
<span class="co1">// Opera 8.0+, Firefox, Safari</span>
ajaxRequest <span class="sy0">=</span> <span class="kw2">new</span> XMLHttpRequest<span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span>
<span class="br0">}</span>
catch <span class="br0">(</span>e<span class="br0">)</span>
<span class="br0">{</span>
<span class="co1">// Internet Explorer Browsers</span>
try
<span class="br0">{</span>
ajaxRequest <span class="sy0">=</span> <span class="kw2">new</span> ActiveXObject<span class="br0">(</span><span class="st0">"Msxml2.XMLHTTP"</span><span class="br0">)</span><span class="sy0">;</span>
<span class="br0">}</span>
catch <span class="br0">(</span>e<span class="br0">)</span>
<span class="br0">{</span>
try
<span class="br0">{</span>
ajaxRequest <span class="sy0">=</span> <span class="kw2">new</span> ActiveXObject<span class="br0">(</span><span class="st0">"Microsoft.XMLHTTP"</span><span class="br0">)</span><span class="sy0">;</span>
<span class="br0">}</span>
catch <span class="br0">(</span>e<span class="br0">)</span>
<span class="br0">{</span>
<span class="co1">// Something went wrong</span>
alert<span class="br0">(</span><span class="st0">"Your browser broke!"</span><span class="br0">)</span><span class="sy0">;</span>
<span class="kw1">return</span> <span class="kw4">false</span><span class="sy0">;</span>
<span class="br0">}</span>
<span class="br0">}</span>
<span class="br0">}</span>
<span class="br0">}</span>
 
<span class="kw2">function</span> getInfo<span class="br0">(</span>kode<span class="br0">)</span>
<span class="br0">{</span>
getAjax<span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span>
ajaxRequest<span class="sy0">.</span>open<span class="br0">(</span><span class="st0">"GET"</span><span class="sy0">,</span><span class="st0">"bukainfo.php?kode="</span> <span class="sy0">+</span> kode<span class="br0">)</span><span class="sy0">;</span>
ajaxRequest<span class="sy0">.</span>onreadystatechange <span class="sy0">=</span> <span class="kw2">function</span><span class="br0">(</span><span class="br0">)</span>
<span class="br0">{</span>
document<span class="sy0">.</span>getElementById<span class="br0">(</span><span class="st0">"info"</span><span class="br0">)</span><span class="sy0">.</span>innerHTML <span class="sy0">=</span> ajaxRequest<span class="sy0">.</span>responseText<span class="sy0">;</span>
<span class="br0">}</span>
ajaxRequest<span class="sy0">.</span>send<span class="br0">(</span><span class="kw4">null</span><span class="br0">)</span><span class="sy0">;</span>
<span class="br0">}</span>
<span class="kw2"></script></span>
<span class="sy0"></</span>head<span class="sy0">></span>
<span class="sy0"><</span>body<span class="sy0">></span>
<span class="sy0"><</span>table align<span class="sy0">=</span><span class="st0">"center"</span><span class="sy0">></span>
<span class="sy0"><</span>tr<span class="sy0">></span>
<span class="sy0"><</span>td<span class="sy0">></span>
<span class="sy0"><</span>img src<span class="sy0">=</span><span class="st_h">'koordinat.php'</span> usemap <span class="sy0">=</span><span class="st_h">'#negara'</span><span class="sy0">></span>
<span class="sy0"><</span>map name<span class="sy0">=</span><span class="st_h">'negara'</span><span class="sy0">></span>
<span class="kw2"><?php</span>
<span class="re0">$querytitik</span> <span class="sy0">=</span> <span class="kw3">mysql_query</span><span class="br0">(</span><span class="st0">"SELECT x,y,kabupaten FROM koordinat"</span><span class="br0">)</span><span class="sy0">;</span>
<span class="kw1">while</span><span class="br0">(</span><span class="re0">$titik</span> <span class="sy0">=</span> <span class="kw3">mysql_fetch_row</span><span class="br0">(</span><span class="re0">$querytitik</span><span class="br0">)</span><span class="br0">)</span>
<span class="br0">{</span>
<span class="re0">$minx</span> <span class="sy0">=</span> <span class="re0">$titik</span><span class="br0">[</span><span class="nu0">0</span><span class="br0">]</span><span class="sy0">-</span><span class="nu0">3</span><span class="sy0">;</span>
<span class="re0">$miny</span> <span class="sy0">=</span> <span class="re0">$titik</span><span class="br0">[</span><span class="nu0">1</span><span class="br0">]</span><span class="sy0">-</span><span class="nu0">3</span><span class="sy0">;</span>
<span class="re0">$maxx</span> <span class="sy0">=</span> <span class="re0">$titik</span><span class="br0">[</span><span class="nu0">0</span><span class="br0">]</span><span class="sy0">+</span><span class="nu0">3</span><span class="sy0">;</span>
<span class="re0">$maxy</span> <span class="sy0">=</span> <span class="re0">$titik</span><span class="br0">[</span><span class="nu0">1</span><span class="br0">]</span><span class="sy0">+</span><span class="nu0">3</span><span class="sy0">;</span>
<span class="sy1">?></span>
<area shape='rect' coords='<span class="sy1"><?=</span><span class="re0">$minx</span><span class="sy0">.</span><span class="st0">","</span><span class="sy0">.</span><span class="re0">$miny</span><span class="sy0">.</span><span class="st0">","</span><span class="sy0">.</span><span class="re0">$maxx</span><span class="sy0">.</span><span class="st0">","</span><span class="sy0">.</span><span class="re0">$maxy</span><span class="sy1">?></span>' href="javascript:getInfo('<span class="sy1"><?=</span><span class="re0">$titik</span><span class="br0">[</span><span class="nu0">2</span><span class="br0">]</span><span class="sy1">?></span>');"> <!-- daftar link lokasi -->
<span class="kw2"><?php</span>
<span class="br0">}</span>
<span class="sy1">?></span>
 
</map>
</td>
<td valign='top' id='info'></td>
</tr>
</table>
</body>
</html>
 
?>
 
< /pre>
 
 
koordinat.php :
 
<pre lang="php">
<span class="kw2"><?php</span>
<span class="kw3">mysql_connect</span><span class="br0">(</span><span class="st0">"localhost"</span><span class="sy0">,</span><span class="st0">"root"</span><span class="sy0">,</span><span class="st0">""</span><span class="br0">)</span><span class="sy0">;</span> <span class="co1">//koneksi ke database mysql</span>
<span class="kw3">mysql_select_db</span><span class="br0">(</span><span class="st0">"dbxx"</span><span class="br0">)</span><span class="sy0">;</span>
 
<span class="re0">$peta</span> <span class="sy0">=</span> <span class="kw3">imagecreatefromjpeg</span><span class="br0">(</span><span class="st0">"peta.jpg"</span><span class="br0">)</span><span class="sy0">;</span> <span class="co1">//membuka gambar peta dunia</span>
<span class="re0">$warna</span> <span class="sy0">=</span> <span class="kw3">imagecolorallocate</span> <span class="br0">(</span><span class="re0">$peta</span><span class="sy0">,</span> <span class="nu0">255</span><span class="sy0">,</span><span class="nu0">0</span><span class="sy0">,</span><span class="nu0">0</span><span class="br0">)</span><span class="sy0">;</span> <span class="co1">//menentukan warna titik lokasi pada peta</span>
 
<span class="re0">$querytitik</span> <span class="sy0">=</span> <span class="kw3">mysql_query</span><span class="br0">(</span><span class="st0">"SELECT x,y FROM koordinat"</span><span class="br0">)</span><span class="sy0">;</span> <span class="co1">//query informasi koordinat lokasi</span>
<span class="kw1">while</span><span class="br0">(</span><span class="re0">$titik</span> <span class="sy0">=</span> <span class="kw3">mysql_fetch_row</span><span class="br0">(</span><span class="re0">$querytitik</span><span class="br0">)</span><span class="br0">)</span>
<span class="br0">{</span>
<span class="re0">$x</span> <span class="sy0">=</span> <span class="re0">$titik</span><span class="br0">[</span><span class="nu0">0</span><span class="br0">]</span><span class="sy0">;</span>
<span class="re0">$y</span> <span class="sy0">=</span> <span class="re0">$titik</span><span class="br0">[</span><span class="nu0">1</span><span class="br0">]</span><span class="sy0">;</span>
<span class="kw3">imagefilledrectangle</span><span class="br0">(</span><span class="re0">$peta</span><span class="sy0">,</span><span class="re0">$x</span><span class="sy0">-</span><span class="nu0">3</span><span class="sy0">,</span><span class="re0">$y</span><span class="sy0">-</span><span class="nu0">3</span><span class="sy0">,</span><span class="re0">$x</span><span class="sy0">+</span><span class="nu0">3</span><span class="sy0">,</span><span class="re0">$y</span><span class="sy0">+</span><span class="nu0">3</span><span class="sy0">,</span><span class="re0">$warna</span><span class="br0">)</span><span class="sy0">;</span> <span class="co1">//membuat titik kotak pada peta</span>
<span class="br0">}</span>
 
 
<span class="kw3">header</span><span class="br0">(</span><span class="st0">"Content-Type: image/jpeg"</span><span class="br0">)</span><span class="sy0">;</span> <span class="co1">//menampilkan file gambar</span>
<span class="kw3">imagejpeg</span><span class="br0">(</span><span class="re0">$peta</span><span class="br0">)</span><span class="sy0">;</span>
<span class="kw3">imagedestroy</span><span class="br0">(</span><span class="re0">$peta</span><span class="br0">)</span><span class="sy0">;</span>
<span class="sy1">?></span></pre></div></td></tr></table></div>
Tagged:
Sign In or Register to comment.