2

I have a Google Maps interface on my website which allows people to drop and place various custom markers etc.

Is there any way of allowing people to save these? or for them to be copied onto a unique link in the website that the user can access?

MRDJR97
  • 656
  • 2
  • 8
  • 22

2 Answers2

1

You can also use localStorage with JSON to keep objects in the user's device. You can try this code:

var whatYouWhantToKeep={};
whatYouWhantToKeep.position.lat=marker.getPosition().lat;
whatYouWhantToKeep.position.lng=marker.getPosition().lng;
whatYouWhantToKeep.icon=yourIcon.src;
localStorage.setItem ('aSpecialKey', JSON.stringify(whatYouWhantToKeep));

And after get what you wanted to keep with your key:

var whatYouWhantToKeep = JSON.parse (localStorage.getItem ('aSpecialKey'));

You have to use JSON because localStorage accept only strings.

SphynxTech
  • 1,476
  • 1
  • 15
  • 33
0

I think you can keep them in you database,then next the user login ,you can load the data from database.

//the locations is the places user defined.
var markers = locations.map(function(location, i) {
      return new google.maps.Marker({
        position: location,
        icon: "the img user defined"
      });
    });
shangzhouwan
  • 104
  • 4