Page 1 of 1

Phoca Maps does not obey zoom level with KML file

Posted: 29 Jun 2014, 16:28
by Discus
I have a fairly long (~100kb) kml file with polygons from around the world. Without the KML file loaded, the map plugin nicely shows me the whole world. However, as soon as I tell the component to display the KML, the zoom level is ignored, and the map zooms way out, showing the world several times. see e.g. http://draft.marinehotspots.org/hotspot ... s-map.html (test/test, if asked).

No matter what zoom level I set it on, this happens. I have set it to start at lat/long 0/0 (equator, Greenwich) within Phoca, and tried zoom levels from 0 to 14. This is on the latest version of Joomla 3.x with the latest Phoca Maps plugin and component.

Unfortunately, the KML is too long to paste here, due to character limits (it's about 100kb of plain text!), and I can't see any way of attaching the file to this post. I'm wary of adding another link in case this post is seen as "spammy" by the protection script.

I can manually set the zoom level once it loads (going two levels up from the bottom seems about right), but this is a bit clunky and looks (very) ugly on load.

I have my suspicions that this occurs because the polygons extend over the "edges" of the map (what with the globe being spherical and all), but I can't seem to figure out any way of "bounding" the view within KML or PhocaMaps.

Any ideas? Many thanks! :)

Re: Phoca Maps does not obey zoom level with KML file

Posted: 30 Jun 2014, 22:07
by Jan
Hi, I see.

In the html source code, you can see:

Code: Select all

var phocaOptions = {
   zoom: 14,
   center: phocaLatLng,
   mapTypeControl: true,
   mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DEFAULT, 
   position: google.maps.ControlPosition.TOP },
   navigationControl: true,
   navigationControlOptions: {style: google.maps.NavigationControlStyle.DEFAULT},
   scaleControl: true,
   scrollwheel: 1,
   disableDoubleClickZoom: 0,
   mapTypeId: google.maps.MapTypeId.SATELLITE
 };
that the zoom is correctly set, so the only one idea is, something in the KML reset the default zoom level.

I see the KML in the source, so you don't need to add it here. There is no zoom settings but maybe this:

Code: Select all

<LatLonAltBox>
        <north>180</north>
        <south>-180</south>
        <east>-180</east>
        <west>180</west>
      </LatLonAltBox>
cuases that the zoom is set as it is :idea: (but maybe this should be some question on Google Maps API developer :idea: )

Jan

Re: Phoca Maps does not obey zoom level with KML file

Posted: 06 Jul 2014, 12:14
by Discus
Thanks Jan - the region and <LatLonAltBox> was my attempt (clearly not working!) to try to set the boundaries being displayed; the behaviour is the same whether or not it is in the .kml. I've edited it out again, and the problem remains.

I've submitted a question to StackOverflow
http://stackoverflow.com/questions/2459 ... oogle-maps
The KML (without the Region set) is available from http://pastebin.com/wqTXaq38

Re: Phoca Maps does not obey zoom level with KML file

Posted: 11 Jul 2014, 21:48
by Jan
Ok

Re: Phoca Maps does not obey zoom level with KML file

Posted: 03 Aug 2014, 16:19
by Discus
"Sounds like you need the preserveViewport option of the KmlLayer"
According to one post on my StackOverflow submission
http://stackoverflow.com/questions/2459 ... oogle-maps

Does PhocaMaps already use preserveViewport?
https://developers.google.com/maps/docu ... er_options

Thanks!

Re: Phoca Maps does not obey zoom level with KML file

Posted: 05 Aug 2014, 22:52
by Jan
Hi, no, there is no instruction for preserveViewport in the code, so the javascript code of the Phoca Maps needs to be customized :idea:

Jan