mapSend.php 2.21 KB
Newer Older
Piyawat jangin's avatar
Piyawat jangin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAeNsNnRXUdrpgSw3qfvhz5hRHchrjOSPM-moa2HMmJZw-0fE6VhTsARfVd9x1Dg8TowZALqHIOcO20g"
type="text/javascript"></script>
<script type="text/javascript">
    // Create a directions object and register a map and DIV to hold the 
// resulting computed directions


  
<?php
$data = $model->getData();

$dataProvider = $provider->getData();
?>
    var map;
    var directionsPanel;
    var directions;

    function onGDirectionsLoad() {
        var route = directions.getRoute(0);
        var x = route.getNumSteps();
        var turn = [];
        for (i = 0; i < x; i++) {
            var step = route.getStep(i);
            turn[i] = step.getLatLng();
            alert(turn[i]);
        }
    }

    function initialize() {
        map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(13.998, 100.5009), 15);
        directionsPanel = document.getElementById("route");
        directions = new GDirections(map, directionsPanel);
        directions.load("from:<?php echo $dataProvider[0]->lati; ?>,<?php echo $dataProvider[0]->longi; ?> to:<?php echo $data[0]->lati; ?>,<?php echo $data[0]->longi; ?> ", {locale: 'th'});
//15.24843936771309, 104.6200704957032

        GEvent.addListener(directions, "load", onGDirectionsLoad);
    }
    
    function print() {
        var contents = window.document.getElementById("map_canvas"); 
    document.write(contents.innerHTML); 
    window.print(); 
//var contents = window.opener.document.getElementById("map_container");
//document.write(contents.innerHTML);
//window.print();
    }
    
</script>
</head> 


<div id="map_canvas" style="width: 70%; height: 480px; float:left; border: 1px solid black;">

</div> 
<div id="route" style="width: 25%; height:480px; float:right; border; 1px solid black;"> 
    <?php
    $imghtml = CHtml::image('images/icon/delivery_food.png', "เพิ่มข้อมูล", array("width" => 50));
    echo CHtml::link($imghtml, array('admin/UpdateSend', 'id' => $id, array(
            'htmlOptions' => array(
                'title' => 'ส่งอาหาร'
            )
    )));
    echo "<br><b>จัดส่งอาหาร";
//echo $id;
    ?>

</div> 

<br/>