PDA

View Full Version : problem map move



dussla
04-06-2014, 02:53 AM
i made some code
that is auto map move
but in for senetenc is error
THIS code purpose is stop and capture when code array move

but for senetence is not good
can you fix


<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>map</title>
<script type="text/javascript" src="http://apis.daum.net/maps/maps3.js?apikey=966170c5c60229653d09bd765ddbdc2867ab2381" charset="utf-8"></script>
<script type="text/javascript">
function init() {
map = new daum.maps.Map(document.getElementById('map'), {
center: new daum.maps.LatLng(37.537123, 127.005523),
level: 3
});

}




function x_pan()

{

map.panBy(200 , 0);


}


function y_pan( )

{


map.panBy(0 , 200 );


}



function mpanby() {

var xsize =5000 ;
var ysize = 5000 ;
var fixx = 1000 ;
var fixy = 1000 ;
var ber = xsize / fixx ;
var yber = ysize / fixy ;
var xnumber = parseInt(ber) ;
var ynumber = parseInt(yber) ;


for(var yi = 1; yi <= ynumber; yi++) {





for(var i = 1; i <= xnumber; i++) {



x_pan() ;

}



y_pan() ;
}




}

</script>
</head>
<body onload="init()">
<div id="map" style="width:1600px;height:800px;"></div>

<form>
<div id="message" style="font-size:12px;width:590px;height:30px;border:solid 1px black;padding:5px;"></div>

<button type="button" onclick="mpanby()"> move</button>

</form>
</body>
</html>

jscheuer1
04-06-2014, 06:36 AM
I think you may just need a valid api key. Is this the error you are getting:


API 로드 실패: 올바른 Referer가 아닙니다. 등록한 사용URL을 확인하세요

If so, I'm pretty sure you just need a valid api key. I reworked the code using Google maps which doesn't require a key, at least not for local testing, and it works fine:


<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>map</title>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false" charset="utf-8"></script>
<script type="text/javascript">
function init() {
map = new google.maps.Map(document.getElementById('map'), {
center: new google.maps.LatLng(37.537123, 127.005523),
zoom: 15
});

}




function x_pan()

{

map.panBy(200 , 0);


}


function y_pan( )

{


map.panBy(0 , 200 );


}



function mpanby() {

var xsize =5000 ;
var ysize = 5000 ;
var fixx = 1000 ;
var fixy = 1000 ;
var ber = xsize / fixx ;
var yber = ysize / fixy ;
var xnumber = parseInt(ber) ;
var ynumber = parseInt(yber) ;


for(var yi = 1; yi <= ynumber; yi++) {





for(var i = 1; i <= xnumber; i++) {



x_pan() ;

}



y_pan() ;
}




}

</script>
</head>
<body onload="init()">
<div id="map" style="width:1600px;height:800px;"></div>

<form>
<div id="message" style="font-size:12px;width:590px;height:30px;border:solid 1px black;padding:5px;"></div>

<button type="button" onclick="mpanby()"> move</button>

</form>
</body>
</html>

At least there are no errors and the move button works for moving the map. No message appears in the message div, but there's no mention of that div in the javascript code on the page. If you want to use daum maps, then you probably need an account and a key from here:

http://login.daum.net/accounts/loginform.do?daumauth=1&category=openapi&url=https://dna.daum.net/myapi