1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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

Discussion in 'Resource Discussions [Archive]' started by Marc, May 22, 2011.

  1. Marc

    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



    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
  2. steven s

    steven s Well-Known Member

  3. Marc

    Marc Well-Known Member

    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
    Tim likes this.
  4. James

    James Well-Known Member

    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.
  5. Marc

    Marc Well-Known Member

    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.
  6. Marc

    Marc Well-Known Member

    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.
  7. James

    James Well-Known Member

    Can you post your DW code to check if it's correct?
  8. Bellinis

    Bellinis Active Member

    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!
  9. Marc

    Marc Well-Known Member

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

            public function actionAddLocation()
    // this action must be called via POST

    // guests not allowed

    // 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');

    // redirect back to the normal dcXenMapMe index page
    return $this->responseRedirect(
    This is the code in my datawriter

    class dcXenMapMe_DataWriter_NewMarker extends XenForo_DataWriter
        protected function 
            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)

    <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 class="ctrlUnit submitUnit">
            <dd><input type="submit" value="Add" class="button primary" accesskey="s" /></dd>
        <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
    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
  10. ragtek

    ragtek Guest

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

        <dd><input type="text" name="message" id="ctrl_location" class="textCtrl"</input></dd>
    You need the name attribute!
    Marc likes this.
  11. Marc

    Marc Well-Known Member

    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?
  12. Marc

    Marc Well-Known Member

    Any idea m8.... A bit lost lol
  13. James

    James Well-Known Member

    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)
  14. Marc

    Marc Well-Known Member

    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.
  15. James

    James Well-Known Member

    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.
  16. Marc

    Marc Well-Known Member

    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
  17. leftie

    leftie Active Member

    I swear one of those blue pins near Wolverhampton is right by my house.
  18. Marc

    Marc Well-Known Member

    You know anyone right near your house who happens to have a husky? LOL
  19. Kier

    Kier XenForo Developer Staff Member

    Is that all the code in your DataWriter?
    Marc likes this.
  20. Marc

    Marc Well-Known Member

    Uh oh, this sounds like I messed this up pretty royally LOL ....... It is yeah.

Share This Page