I have a map from which I want to select through javascript, a rectangular zone from my googlemap map. After this, I want to perform an action by sending the two corner coordonates (that I have took) to my Cakephp Controller, without clicking anywhere. How can I perform it please?
hint: I use the 1.3 cakephp version. Thanks.
here is my code:
var map, bnds, dz;
function initialize() {
...
dz= map.GetDragZoomObject();
...
google.maps.event.addListener(dz,'dragend', function(bnds){
//variable to be display: bnds
alert('KeyDragZoom end: ' + bnds);
}
The alert shows me this message in a alertbox:
"KeyDragZoom end: ((1.53790123, 9.404296), (5.22600788, 18.391113281))
you can try using jquery $.ajax to send the data back to the server. This example handles a response back from the server as well.
$.ajax({
url: "<?php echo $html->url( array( 'controller' => 'xxx', 'action' => 'xxx' ), true ) ?>",
dataType: "json",
crossDomain: false,
data: bnds
})
.then( function ( response ) {
$.each(response, function (i, val) {
// do something
});
});
The documentation for ajax is here if you need it https://api.jquery.com/jQuery.ajax/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.