Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- $(document).ready(function() {
- // var pic = 'http://muzeum.pyramidlab.pl/uploads/Maps/muzeum.jpg';
- var pic;
- $('#Exhibits_isVisible').change(function(){
- if($('#Exhibits_isVisible').is(':checked'))
- $(this).attr('value','1');
- else
- $(this).attr('value','0');
- });
- display = function(value) {
- // $('#test').html("Id wybranej mapy: " + value);
- /*$.getJSON( ", function( data ) {
- console.log(data);
- $('#test').html("URl wybranej mapy: " + data);
- });*/
- $.ajax({
- //dataType: "json",
- url: "<?php echo $this->createUrl('/map/getPictureMapById') ?>/id/" + value,
- success: function(data){
- // console.log(data);
- //$('#test').html("URl wybranej mapy: " + data);
- pic = data;
- console.log(pic);
- }
- });
- };
- function invokeMap(){
- var floorOverlay;
- var centerOfTheMap = new google.maps.LatLng(51.246613, 22.567874);
- var swBound = new google.maps.LatLng(51.245522, 22.565557);
- var neBound = new google.maps.LatLng(51.247403, 22.569746);
- var imageBounds = new google.maps.LatLngBounds(swBound, neBound);
- var allowedBounds = new google.maps.LatLngBounds(
- new google.maps.LatLng(51.246294, 22.567010),
- new google.maps.LatLng(51.246926, 22.568571)
- );
- var mapOptions = {
- zoom: 19,
- zoomControl: false,
- scrollwheel: false,
- disableDefaultUI: true,
- disableDoubleClickZoom: true,
- center: centerOfTheMap
- };
- var map = new google.maps.Map(document.getElementById('map'),
- mapOptions);
- var boundLimits = {
- maxLat : allowedBounds.getNorthEast().lat(),
- maxLng : allowedBounds.getNorthEast().lng(),
- minLat : allowedBounds.getSouthWest().lat(),
- minLng : allowedBounds.getSouthWest().lng()
- };
- var lastValidCenter = map.getCenter();
- var newLat, newLng;
- google.maps.event.addListener(map, 'center_changed', function() {
- center = map.getCenter();
- if (allowedBounds.contains(center)) {
- lastValidCenter = map.getCenter();
- return;
- }
- newLat = lastValidCenter.lat();
- newLng = lastValidCenter.lng();
- if(center.lng() > boundLimits.minLng && center.lng() < boundLimits.maxLng){
- newLng = center.lng();
- }
- if(center.lat() > boundLimits.minLat && center.lat() < boundLimits.maxLat){
- newLat = center.lat();
- }
- map.panTo(new google.maps.LatLng(newLat, newLng));
- });
- var marker = new google.maps.Marker({
- position: centerOfTheMap,
- map: map,
- draggable:true,
- //title:""
- });
- function countBounds() {
- var mapBounds = map.getBounds();
- var lewyDolny = mapBounds.getSouthWest();
- var prawyGorny = mapBounds.getNorthEast();
- var lewo = mapBounds.lng();
- var prawo = mapBounds.lng();
- var gora = mapBounds.lat();
- var dol = mapBounds.lat();
- var prawyDolny = new google.maps.LatLng(dol,prawo);
- var lewyGorny = new google.maps.LatLng(gora,lewo);
- }
- google.maps.event.addListener(marker, 'dragend', function (event) {
- document.getElementById("Exhibits_mapPositionX").value = this.getPosition().lat();
- document.getElementById("Exhibits_mapPositionY").value = this.getPosition().lng();
- });
- floorOverlay = new google.maps.GroundOverlay(
- // 'http://muzeum.pyramidlab.pl/uploads/Maps/muzeum.jpg',
- pic,
- imageBounds);
- floorOverlay.setMap(map);
- console.log(pic);
- };
- invokeMap();
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement