How do I store the markers locations and data?

0 favourites
  • 11 posts
From the Asset Store
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • A little introduction:

    I am creating a map of the town I live in. The map will be used by a group of volunteers that can mark locations on the map that need maintenance or litter picking.

    What I have so far is..

    • A map of the town with zoom and move functions either by pressing buttons (sprites) or by using the mouse.
    • A red and green button (sprites) which will activate the marking process.

    When clicked all buttons will go invisible and a colored pin starts following the mouse.

    When you click on the map after that you place the pin on the map. That pin will then also be moved with the zoom and scroll functions of the map. All buttons will become visible again allowing you to add another marker.

    My question is..

    How do I store the markers placed on the map to a database?

    And how do I load them again when someone else opens the webpage with the map?

    So just for the record.. I want everyone to use the same saved data and add to it or change it.

    Some red markers will for example be changed into a green one when some problem area has been taken care of.

    Another question..

    I also want to add the users name (from a variable set on login) to the marker and add the date when the marker was placed so these will also have to be stored.

    Can I make a textballoon like way of showing this user name and date when an existing marker is clicked?

    Have a look at the capx if you want..

    https://dl.dropboxusercontent.com/u/175 ... rkers.capx

    Thanks for reading,

    Danny

    P.S.

    The name of the placed markers/ pins are 'pingreenplaced' and 'pinredplaced'. They are on layer 2.

    They will be placed by CanvasToLayer because the layer is being scaled when zooming in and out. So the mouse position doesn't always directly correspond to the visual spot on the layer. I hope this makes sense.

  • Store marker, each time someone places one, simply have it send their name/ID combined with an X,Y coordinate relative to your map. (I would add a status too, like cleaned, waiting etc )

    When the Map loads, fire a call that simply retrieves the entire list of markers, statuses and names, and place them in an array.

    Then just have it show the markers location, and on touch/click, show a popup balloon with the info from the array associated with the marker.

  • I notice it is often you that saves the day Lennaert..

  • yes I'd have it read from an online DB that you can modify if need be. i.e. delete mistakes etc..

    how many users will you have at once? I would only allow "adds" to the DB as it's a much harder system to put in place if it allowed people to delete pins they've added.

    I like using RexRainbow's CSV plugin, it's easy to use, I use it instead of arrays a lot. Although I have to admit I've never written it to a central place where multiple client-apps are reading from it. I also saw another of his plugins called Firebase.. might be overkill for what you are doing, but worth a look.

  • There will be roughly 50 members so not likely more than a couple will use it at once. This is why I already decided to only send to database the current pin/marker that user is placing or modifying. I don't want people to often overwrite each others data by accident. If it happens once every now and then so be it. I know how to write to database now a bit so that is not really a problem, but I am not sure about specific problems this specific project will cause. For example..

    If I have 3 markers in the database and the second one will be deleted does this leave a gap in the database or in the array when I load the data into construct? I want to avoid that sort of things as much as possible. If two people are using the map at the same time and one deletes a marker but the other adds one I don't want it to cause a conflict. This basicly means I don't want to number the markers or use the ID in the database for identifying the marker.

    I will figure this out

    It is a wonderful learning project.

    Thank you for recommending the plugins I will make sure to check those out.

  • I would imagine the total data of the markers will be fitting in one ajax request.

    Perhaps then simply poll the database every minute or so, and give a notification if there are changes in the new LastData compared to what the user already had in the construct 2 app.

  • Would you really think that would not be too much info to do all the markers every minute for every user? I mean.. just the locations and status perhaps but if i would allow a description for each marker of let's say 150 characters per marker that becomes a lot of data.. Interesting idea though. I thought every time a change was made just only change that entry in the database and leave all the other markers untouched. Not sure how i would identify the individual markers though since if i would use the database ID and markers get deleted the ID changes.

    So if person A and B both log in..

    Person A edits marker #5..

    At the same time person B deletes marker #4..

    This would cause marker #5 to become marker #4..

    Now when person A is done editting and the system autosaves that data it saves it to the wrong spot in the database.

    Or am I overthinking this now?

    Perhaps when a marker gets deleted I instead of actually removing it I should just make the database entry say DELETED and once a day at a specific moment remove all deleted entries at once?

    *scratches head*

  • Deleting a row in the database won't change the ids of other rows.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • ramones

    Will it just forever be auto incrementing and leaving empty spots then?

  • Yep but there won't have a gap in your results or anything. If you have 3 markers and you delete the second one then when you select all from the database you'll get back 2 markers with ids 1 and 3.

  • In that case i was overthinking..

    Thanks

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)