我是一个非常新手的javascript东西,我现在假装它直到我让它大声笑,现在我遇到了一个小山,我正在努力克服:S.
目前,我的脚本找到用户位置,并在将LatLon复制到某些表单字段时向地图添加图钉.
除了刚刚拉近用户的位置我想他们不得不增加其输入到一个文本字段,地理编码,然后在地图上更新当前销自定义地址的功能.
这一切都有效,虽然它为地图添加了一个额外的引脚,而不是更新当前引脚.
我不确定如何将地址地理编码功能的值传回原始引脚/或删除原始引脚并添加新引脚.我确信我也可以重用一些功能......我不认为我的代码效率非常高:/
无论如何,我希望那里的古茹可以帮助我
干杯尼克
var geocoder;
var map;
var pos;
function initialize() {
geocoder = new google.maps.Geocoder();
var newyork = new google.maps.LatLng(40.69847032728747, -73.9514422416687);
var address = document.getElementById("address").value;
var initialLocation;
var myOptions = {
zoom: 12,
center: initialLocation,
mapTypeId: google.maps.MapTypeId.TERRAIN
}
// Try HTML5 geolocation
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
var marker = new google.maps.Marker({
map: map,
position: pos,
title: 'Location found using HTML5.',
draggable: true
});
var lat = position.coords.latitude
var lng …
Run Code Online (Sandbox Code Playgroud) 你如何得到assocIMG
钥匙匹配钥匙的价值,例如
如果我有一个var 11786
我希望它返回media/catalog/product/8795139_633.jpg
var spConfig = {
"attributes": {
"125": {
"id": "125",
"code": "pos_colours",
"label": "Colour",
"options": [{
"id": "236",
"label": "Dazzling Blue",
"price": "0",
"oldPrice": "0",
"products": ["11148"]
}, {
"id": "305",
"label": "Vintage Brown",
"price": "0",
"oldPrice": "0",
"products": ["11786", "11787", "11788", "11789", "11790", "11791", "11792", "11793"]
}]
}
}
};
var assocIMG = // Added - Removed { here, causes issues with other scripts when not working with a configurable product.
{ …
Run Code Online (Sandbox Code Playgroud)