外部アイコンを使用するためにjavascriptとGoogleマップで関数を作成し、html5キャンバスを使用して再描画しましたが、アイコンのロードの原因であるimageObj.onloadを使用すると、関数は何も返されず、その関数を削除して送信しましたとにかく結果ですが、アイコンとキャンバスを操作する際の正しい形式ではありません 私のコードは
function getIconMarker(course, speed){
course = parseFloat (course) * 0.01745327777;
if (parseInt(speed) != 0) {
imageIcon = '{% static "markers/onmove.gif" %}';
} else {
imageIcon = '{% static "markers/onstop.png" %}';
}
var elemento = document.createElement("canvas");
elemento.width = 80;
elemento.height = 80;
if(elemento && elemento.getContext){
var context = elemento.getContext('2d');
if(context){
var imageObj = new Image();
imageObj.src = imageIcon;
//imageObj.onload = function(){
//console.debug('image loaded');
context.save();
context.translate(imageObj.width, imageObj.height);
context.rotate(course);
context.drawImage(imageObj, -(imageObj.width/2), -(imageObj.height/2));
context.restore();
//console.debug(elemento.toDataURL());
return elemento.toDataURL();
//}
console.debug('image no loaded');
}
console.debug('no context created');
}
console.debug('no context enblaed');
//return imageIcon;
}