• This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

MapMe - Users Google Map

Marc

Well-known member
Although I see there is a usermap of sorts available in the addons section which is excellent in the way that it pins your currently online users, my users have been used to a map of a different kind where they can pin themselves. Therefore getting a map of all the current users on the forum that have pinned themself.

So I have been working on doing an addon similar to the membermap plugin for IPB that we can use for xenforo. Thought I would share a very quick screenie, and will add more as I develop more of it.

Bare in mind please that I have only started this yesterday, and I am also very new to both PHP and plugin development for any system at all. So I am very much learning as I go along. Figured I am a developer, so I should be able to work my head around it LOL ....... We'll see LOL

huskydev.webp

av.webp

Plans for its development:

  • Link the username text to the popup card & get css styling if set
  • Usergroup permissions for view can view/add to the map
  • Admin to be able to set marker image used
  • Custom Markers placeable by admin
  • Was thinking of possibly looking at the alerts and seeing if I can get it to alert people who chose to when someone adds themselves to the map
 

As said in the topic above, this one works differently. Digital points map is excellent, as it shows or the users that are currently online where they are by using geocoding. However mine is user based. The users pin themselves on the map and they stay on the map whether they are online or not. Therefore building a map of where all your members are. Both great systems, just both different in concept. One shows those online automatically, one shows everyone who has pinned themself
 
  • Like
Reactions: Tim
Does this currently work, or is it just a mockup?

If so, things like "Link the username text to the popup card & get css styling if set" should be possible with templates.
 
Does this currently work, or is it just a mockup?

If so, things like "Link the username text to the popup card & get css styling if set" should be possible with templates.

Currently I have got as far as retrieving the markers from the database and placing them onto a googlemap within its own page on xenforo. Havent gone as far as how the users enter them in the first place etc as of yet.

The styling for the info popups is currently hard coded within the index php controller page, however I do indeed plan on getting the info into a template. I just need to figure how to send the user variable to the template and then it should make things a lot easier for styling along with more easily customisable for people who use it.
 
OK so here is what I have working so far (Thanks to information on here)....
  1. Map onto its own xenforo page
  2. Retrieving markers from the database and placing them onto the map
  3. Members name and avatar placed into the info popup
  4. Geocoding function done and tested to ensure I can retrieve the info I need for placing markers.

Now I am struggling a bit. Is there a tutorial anywhere on using the datawriter properly? All I seem to be getting all the time is "Unspecified Error" when Im trying to write to the database, but to be honest Im not even sure its calling the corrent functions or the datawriter is even set up correctly as Im struggling to get my head around it to understand how it works.

My appologies if I sound thick btw. I am very very new to PHP and so obviously new to coding addons, so Im actually attempting something that is quite big for me to do. However I wanted to throw myself in at the deep end as to start with I needed this addon, and I feel I will learn more by giving myself as much exposure as I possibly can to it.
 
Marc, what a great idea!!
This is something I've been waiting for for a very long time. :)

I hope you'll continue coding and release it as an add-on in the near future!

Thanks and good luck!
 
OK this is the code I have in my index page in controllerPublic which I want to process the results entered into a textbox

PHP:
        public function actionAddLocation()
    {
        // this action must be called via POST
        $this->_assertPostOnly();

        // guests not allowed
        $this->_assertRegistrationRequired();

        // the user is the current visitor
        $userId = XenForo_Visitor::getUserId();

        // fetch and clean the message text from input
        $address = $this->_input->filterSingle('message', XenForo_Input::STRING);

        $lonLat = geoCoder($address);

        // create a new DataWriter and set member_id, lon and lat
        $writer = XenForo_DataWriter::create('dcXenMapMe_DataWriter_NewMarker');
        $writer->set('member_id', $userId);
        $writer->set('lon', $lonLat['lon']);
        $writer->set('lat', $lonLat['lat']);
        $writer->save();

        // redirect back to the normal dcXenMapMe index page
        return $this->responseRedirect(
            XenForo_ControllerResponse_Redirect::SUCCESS,
            XenForo_Link::buildPublicLink('dcXenMapMe')
        );
    }

This is the code in my datawriter

PHP:
class dcXenMapMe_DataWriter_NewMarker extends XenForo_DataWriter
{
    protected function _getFields()
    {
        return array(
            'dc_MapMe_Markers' => array(
                'marker_id'    => array('type' => self::TYPE_UINT,  'required' => true  'autoIncrement' => true),
                'member_id'    => array('type' => self::TYPE_UINT,  'required' => true),
                'lon'  => array('type' => self::TYPE_FLOAT,  'required' => true),
                'lat'    => array('type' => self::TYPE_FLOAT, 'required' => true)
            )
        );
    }
}

And finally this is the form block from my template (can you guess I tried to learn from scratchpad? and failed LOL)

HTML:
<form action="{xen:link dcXenMapMe}" method="post" class="xenForm AutoValidator ScratchpadQuickNote">
    <dl class="ctrlUnit">
        <dt><label for="ctrl_message">Add your location:</label></dt>
        <dd><input type="text""message" id="ctrl_location" class="textCtrl"</input></dd>
    </dl>
    <dl class="ctrlUnit submitUnit">
        <dt></dt>
        <dd><input type="submit" value="Add" class="button primary" accesskey="s" /></dd>
    </dl>

    <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
</form>

My problem is I have literally guessed at what I am doing, and do not understand it at all. I'm guessing the the xen:link should be running back to the main page which is www.mysite/myForumFolder/dcXenMapMe/ however unsure as to how it would know to use the actionAddLocation function ... Guessing Im def missing something here.

Also the datawriter even if I get it to work and write my entries to the database, I want it to check is there is already an entry for that member_id and then alter that one instead if it exists. Dont even know where to start with that bit so was going to do a check in the database and delete the record that already exists using a delete sql statement, then use the datawriter to insert LMAO.... Im tying myself in knots and not sure whether Im getting frustrated or its amusing me LOL
 
OK this is the code I have in my index page in controllerPublic which I want to process the results entered into a textbox

PHP:
        public function actionAddLocation()
    {
        // this action must be called via POST
        $this->_assertPostOnly();

        // guests not allowed
        $this->_assertRegistrationRequired();

        // the user is the current visitor
        $userId = XenForo_Visitor::getUserId();

        // fetch and clean the message text from input
        $address = $this->_input->filterSingle('message', XenForo_Input::STRING);

...
}

And finally this is the form block from my template (can you guess I tried to learn from scratchpad? and failed LOL)

HTML:
<form action="{xen:link dcXenMapMe}" method="post" class="xenForm AutoValidator ScratchpadQuickNote">
    <dl class="ctrlUnit">
        <dt><label for="ctrl_message">Add your location:</label></dt>
        <dd><input type="text""message" id="ctrl_location" class="textCtrl"</input></dd>
    </dl>
    <dl class="ctrlUnit submitUnit">
        <dt></dt>
        <dd><input type="submit" value="Add" class="button primary" accesskey="s" /></dd>
    </dl>

    <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
</form>

<dd><input type="text""message" id="ctrl_location" class="textCtrl"</input></dd>
should be changed in

Code:
    <dd><input type="text" name="message" id="ctrl_location" class="textCtrl"</input></dd>

You need the name attribute!
 
<dd><input type="text""message" id="ctrl_location" class="textCtrl"</input></dd>
should be changed in

Code:
    <dd><input type="text" name="message" id="ctrl_location" class="textCtrl"</input></dd>

You need the name attribute!
Oh aye ... Typos never help do they? LOL Cheers for that.

Still get unspecified error though. Is there anywhere I can find what this error actually is?
 
This is more advanced than I've ever delved. Have you checked your javascript console for any error messages?

(Sorry for long reply, I didn't get alerted until you quoted me, I must've ignored a previous alert)
 
This is more advanced than I've ever delved. Have you checked your javascript console for any error messages?

(Sorry for long reply, I didn't get alerted until you quoted me, I must've ignored a previous alert)

Nps, thats why I quoted ya .... I love this alerts system, I really do LOL. No problems with the javascript. Gonna have another look through other peoples mods to see if I can work out how this is supposed to work. Im sure Ive missed something fundimental. Thankyou for your help anyways James. Helpfull as always :)

Just realised your around the corner (in global terms) too LOL.
 
The JS console doesn't log just JS problems, it logs PHP ones too. You should check it to see if any errors are occurring.
 
The JS console doesn't log just JS problems, it logs PHP ones too. You should check it to see if any errors are occurring.


Oooooo shiny.... :) Will have a look at that, cheers. I really wish I had started with web programming instead of desktop LMAO. VB is so much easier when your used to it lol
 
Top Bottom