How to limit panning in Custom Map Type?

More
12 years 5 months ago #770 by Dima
I'm trying to add this code
Code:
var allowedBounds = new google.maps.LatLngBounds( new google.maps.LatLng(28.70, -127.50), new google.maps.LatLng(48.85, -55.90)); // Listen for the dragend event google.maps.event.addListener(map, 'dragend', function() { if (allowedBounds.contains(map.getCenter())) return; // Out of bounds - Move the map back within the bounds var c = map.getCenter(), x = c.lng(), y = c.lat(), maxX = allowedBounds.getNorthEast().lng(), maxY = allowedBounds.getNorthEast().lat(), minX = allowedBounds.getSouthWest().lng(), minY = allowedBounds.getSouthWest().lat(); if (x < minX) x = minX; if (x > maxX) x = maxX; if (y < minY) y = minY; if (y > maxY) y = maxY; map.setCenter(new google.maps.LatLng(y, x)); });

Don't forget support my developments: post review in JED , donate , help with translation ;)

Please Log in or Create an account to join the conversation.

  • TrainZer
  • Topic Author
  • Offline
  • New Member
  • New Member
More
12 years 5 months ago #771 by TrainZer
Replied by TrainZer on topic Re: How to limit panning in Custom Map Type?
I've done that in default.php now:
Code:
if ((int)$currentmaptype->id == 1) { $scripttext .="// bounds of the desired area var allowedBounds = new google.maps.LatLngBounds( new google.maps.LatLng(70.33956792419954, 178.01171875), new google.maps.LatLng(83.86483689701898, -88.033203125) ); var lastValidCenter = map.getCenter(); google.maps.event.addListener(map, 'center_changed', function() { if (allowedBounds.contains(map.getCenter())) { // still within valid bounds, so save the last valid position lastValidCenter = map.getCenter(); return; } // not valid anymore => return to last valid position map.panTo(lastValidCenter); }); ";

But it doesn't work. I'm testing this on the map type with id 1. What am I doing wrong? Maybe the quotes must be single (''), not double("")?

Please Log in or Create an account to join the conversation.

More
12 years 5 months ago #772 by Dima
give me time, today or tomorrow will be new release, and I gonna add this feature too

Don't forget support my developments: post review in JED , donate , help with translation ;)

Please Log in or Create an account to join the conversation.

  • TrainZer
  • Topic Author
  • Offline
  • New Member
  • New Member
More
12 years 5 months ago #773 by TrainZer
Replied by TrainZer on topic Re: How to limit panning in Custom Map Type?
Thank you! Your component is the best map component I ever seen! Thank you for this component!

Please Log in or Create an account to join the conversation.

More
12 years 5 months ago #774 by Dima
Thanks

This is an alfa version, you can check it.

zhuk.cc/files/com_zhgooglemap-2.10.15-alfa.zip

In map details there is a new field Map Bounds
You have to enter:
latitude1,longitude1;latitude2,longitude2

Don't forget support my developments: post review in JED , donate , help with translation ;)

Please Log in or Create an account to join the conversation.

Time to create page: 0.193 seconds
Powered by Kunena Forum