New Location facility instead of (or in addition to) MapBox

Peter Lane Posted in Component Development 11 months ago

I want to show posts/businesses/events on a map. I would like to ask users entering posts etc to be able to position them on a map. This could either replace the Location field or be associated with it.

Do I have to recognise new entities and objects to ask user? Ideally, I want to replace the Mapbox links, but that seems to involve a few small changes to the code.

Replies
gb Peter Lane Replied 11 months ago

Great! Appreciate your comments so far.

I aim to use these callbacks to manage the locations of these items shown on maps.

German Michael Zülsdorff Replied 11 months ago

Peter,
in doubt just have a look into the class file. And you'll find that in OssnEntities.php the callback gets triggered as

ossn_trigger_callback('delete', 'entity', $vars);

And that's why the registration accordingly has to be

ossn_register_callback('delete', 'entity', 'mycomponentcb');

, and not the other way round.

Indonesian Arsalan Shah Replied 11 months ago

That is correct callback there is no error. Each callback have own type of parameters so putting them in one function is a mistake like i showered you below unless you know what you wanted to do.

I just don't understand what these have to do with your initial question about locations?

gb Peter Lane Replied 11 months ago

I note that the documentation for Entity after delete shows a callback ossn_register_callback('delete', 'entity', 'my_component_cb');

This is different to all the others in that the action 'delete' appears in a different order to other similar calls! Should it not be ossn_register_callback('entity', 'delete', 'my_component_cb');?

gb Peter Lane Replied 11 months ago

Sorry Arsalan and thank you for your patience. I took things on too quickly.

Indonesian Arsalan Shah Replied 11 months ago

But I note that the following don't have an ossn_register_callback function.

It does have a callback and yes you can combine it into one callback.

Example

<?php
function my_component_init(){
     ossn_register_callback('object', 'created', 'my_component_cb');
     ossn_register_callback('object', 'delete', 'my_component_cb');

}
function my_component_cb($callback, $type, $args){
       if($type == 'delete'){ 
              //
        }    
       if($type == 'created'){ 
              //
        }   
}
gb Peter Lane Replied 11 months ago

I will need to use the callbacks noted in the documentation, but I note that the following don't have an ossnregistercallback function.

A callback triggered after object is created
Callback of object after deletation
Callback triggerd when entity is created
A callback triggered after object is created

Is this correct?

Also, please let me know if I may combine some of these calls into one script?

gb Peter Lane Replied 11 months ago

Thank you. Naturally, I wish to avoid editing existing code and want to minimise that.

Indonesian Arsalan Shah Replied 11 months ago

Yes you can use new location facility instead of mapbox. You don't need to recognize old entries. For the new location module you need to bind it to location field and handle the client side. Everything will involve a change either new or edit.