Member
Member
Roland   31-03-2021, 15:55
#1

Hello ! Sorry to bother you peoples, with my PHP level 1 skills.
Thinking it was easy, but I already spend... hours trying to solve it ^^'

Here is the deal :
In picture view if I want to hide the bloc section of the OSM plugin, I wrote this :

if(function_exists('printOpenStreetMap') && (getImageData('EXIFGPSLatitude')!='')) {
echo '';
echo 'Maps';
@call_user_func('printOpenStreetMap');
echo '';
}

And it's working

In Album view, I tried :
if (!empty(printOpenStreetMap())) { ... }
if (!empty(getAlbumGeodata($_zp_current_album))) { ... }
if (!empty(getGeoData())) { ... }
if (!empty(getGeoDataJS())) { ... }

None of them are working. Any clue ?

Thanks !

Administrator
Administrator
acrylian   31-03-2021, 16:33
#2

if (!empty(printOpenStreetMap())) { ... }

This function "prints" and does not return anything. You cannot check if or empty therefore. Most "get" functions return values. In any case read the docs first before using something.

if (!empty(getAlbumGeodata($_zp_current_album))) { ... }
if (!empty(getGeoData())) { ... }
if (!empty(getGeoDataJS())) { ... }

These all are class methods of the openStreetMap class and not standalone functions to use.
https://docs.zenphoto.org/1.5.x/class-openStreetMap.html

To do what you want to do you have to use the class object directly.
https://docs.zenphoto.org/1.5.x/source-class-openStreetMap.html#388-502

Off head this should work:

 $map_object = new openStreetMap(null, $_zp_current_image); // or $_zp_current_album 
 if (!empty( $map_object->geodataJS) && !empty( $map_object->center)) { // this check is used internally to decide if a map should be printed
  //print your html stuff here
   $map_object->printMap();
 }

if you already use if(function_exists('printOpenStreetMap') as a check you don't need to @call_user_func('printOpenStreetMap'); which has the same reason. You need the wrapping check with my code as well. You could also use if(class_exists('openstreetmap')) { or the generalif(extensionEnabled('openstreetmap')) { instead.

Member
Member
Roland   01-04-2021, 11:37
#3

Hello acrylian, thanks for your support ! I'm gonna to try this.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.