Une question qui ne doit pas être compliquée pour un non débutant...
Je voudrais que l'affichage des coordonnées sur la carte google ajoute aussi la possibilité d'entrer ces coordonnées dans un carnet d'adresses
J'ai donc ajouté un formulaire dans le return de generateMarkerHtml: function(m) {
est-ce une bonne méthode ?
Sachant que je fais un test avec un input type="text" pour voir si je lis bien le code postal.
google locator affiche bien sa valeur (44000) avec m.test
comment faire pour que la value de input type="text" name="postcode" l'affiche aussi ?
Javascript ? php ? quelle variable utiliser ? Je n'y arrive pas, besoin d'un coup de main.
Code modifié :
Code origine :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 <script type="text/javascript"> var ex; (function(){ var storeLocator = new UnirgyStoreLocator({ mapEl: $('map'), sidebarEl: $('sidebar'), searchUrl: '<?php echo $this->getUrl('ustorelocator/location/search')?>', generateSidebarHtml: function(m) { return '<b>' + m.title + '</b> (' + parseFloat(m.distance).toFixed(1) + ' ' + m.units + ')<br/>' + m.address_display.replace(/\n/, '<br/>'); }, generateMarkerHtml: function(m) { var url = m.website_url.replace(/\s/,''); return '<b>' + m.title + '</b> <br/>' + m.street_address + ' ' + m.test + ' ' + m.city + '<br/>' + '<br/>' + '<form action="<?php echo $this->getSaveUrl() ?>" method="post" name="formulaire" id="form-validate">' + '<input type="hidden" name="country_id" value="" />' + '<input type="text" name="telephone" value="<?php echo $this->__('my default shipping address') ?>" />'+ '<br/>' + '<input type="text" name="postcode" value="" />'+ '<br/>' + '<input type="hidden" name="default_shipping" value="1" />' + '<button type="submit" title="<?php echo $this->__('my default shipping address') ?>" class="button"><span><span><?php echo $this->__('my default shipping address') ?></span></span></button>' + '<br/>' + '</form>' + '<br/>' + (m.phone.length>5 ? m.phone + '<br/>' : '') + (url.length>5 ? '<a href="' + (url.match(/@/) ? 'mailto:' : '') + url + '"><strong>' + url + '</strong></a><br/>' : '') /* + '<p>Product Types: ' + (m.product_types.match(/baby/) ? 'Custom Baby; ' : '') + (m.product_types.match(/wedding/) ? 'Custom Wedding; ' : '') + (m.product_types.match(/card/) ? 'Greeting Cards; ' : '') + '</p>'*/ + '<p>' + m.notes + '</p>'; } });
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 <script type="text/javascript"> var ex; (function(){ var storeLocator = new UnirgyStoreLocator({ mapEl: $('map'), sidebarEl: $('sidebar'), searchUrl: '<?php echo $this->getUrl('ustorelocator/location/search')?>', generateSidebarHtml: function(m) { return '<b>' + m.title + '</b> (' + parseFloat(m.distance).toFixed(1) + ' ' + m.units + ')<br/>' + m.address_display.replace(/\n/, '<br/>'); }, generateMarkerHtml: function(m) { var url = m.website_url.replace(/\s/,''); return '<b>' + m.title + '</b> <br/>' + m.street_address + ' ' + m.test + ' ' + m.city + '<br/>' + (m.phone.length>5 ? m.phone + '<br/>' : '') + '<br/>' + (url.length>5 ? '<a href="' + (url.match(/@/) ? 'mailto:' : '') + url + '"><strong>' + url + '</strong></a><br/>' : '') /* + '<p>Product Types: ' + (m.product_types.match(/baby/) ? 'Custom Baby; ' : '') + (m.product_types.match(/wedding/) ? 'Custom Wedding; ' : '') + (m.product_types.match(/card/) ? 'Greeting Cards; ' : '') + '</p>'*/ + '<p>' + m.notes + '</p>'; } }); Event.observe(window, 'load', function () { storeLocator.load(); <?php if ($_defaultLocation): ?> $('storelocator-results').style.visibility = 'visible'; storeLocator.search('<?php echo addslashes($_defaultLocation) ?>', { radius: '<?php echo addslashes($_defaultRadius) ?>' /*, type: $('product_type').value*/ }); <?php endif ?> }); Event.observe(window, 'unload', GUnload); <?php if ($_showSearch): ?> Event.observe($('store_locator_form'), 'submit', function() { $('storelocator-results').style.visibility = 'visible'; storeLocator.search($('address').value, { radius: $('radius').value /*, type: $('product_type').value*/ }); }); <?php endif ?> })(); </script>
Partager