2017-08-01 54 views

回答

0

我觉得你可以把它们保存在你的数据库中,然后下一个用户登录,就可以从数据库加载数据。

//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" 
     }); 
    }); 
1

您还可以使用localStorage和JSON将对象保留在用户的设备中。你可以试试这个代码:

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

并得到之后,你想保持你的重点是什么:

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

你必须使用JSON,因为localStorage的只接受字符串。