I am trying to create areamap using map.js
I am using the code as follow :
js
<script src="<?php echo plugins_url('/scripts/jquery.min.js', __FILE__); ?>" type="text/javascript"></script>
<script src="<?php echo plugins_url('/bootstrap/js/bootstrap-tooltip.js', __FILE__); ?>" type="text/javascript"></script>
<script src="<?php echo plugins_url('/bootstrap/js/bootstrap-affix.js', __FILE__); ?>" type="text/javascript"></script>
<script src="<?php echo plugins_url('/bootstrap/js/application.js', __FILE__); ?>" type="text/javascript"></script>
<script src="<?php echo plugins_url('/scripts/jquery.imgareaselect.js', __FILE__); ?>" type="text/javascript"></script>
<?php
$path = plugins_url()."/eNewsPaper/";
?>
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery('img#photo').imgAreaSelect({
handles: true,
});
});
function get_coord(){
var ias = jQuery('#photo').imgAreaSelect({ instance: true });
var imgno = jQuery('#imgno').val();
var res = ias.getSelection();
jQuery.ajax({
type: "POST",
url: "<?php echo $path.'create_image.php'; ?>",
data: { fid:imgno, width : res.width, height : res.height, x1 : res.x1, y1 : res.y1, x2 : res.x2, y2 : res.y2, imgno: imgno },
success: function(data){
jQuery(".container").append(data);
console.log();
}
});
ias.cancelSelection();
var newimgno = parseInt(imgno) + parseInt(1);
jQuery('#imgno').val(newimgno);
}
</script>
html
<input type="text" id="imgno" value="1" /><br />
<input type="button" onclick="get_coord()" value="create this spot" /><br />
<div style="width: 700px; overflow: scroll; float: left;">
<img src="<?php echo $img_src; ?>" id="photo" style="width: 700px;" />
</div>
<div class="container" style="width: 250px; height: 700px; overflow: scroll"></div>
When first time the image is loaded then I am unable to select the area from the image,
but when I click the create this spot button then able to create the area map,
What is the problem why I am not able to slect the area from the first time
Aucun commentaire:
Enregistrer un commentaire