Home Forums Porto Admin Template Use address in gmaps instead of lat long

This topic contains 5 replies, has 2 voices, and was last updated by  Support2 1 week ago. This post has been viewed 61 times

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #10023448

    simplyjessica
    Participant

    How do I use an address instead of the lat long on the gmaps?

    			var initBasicWithMarkers = function() {
    				var map = new GMaps({
    					div: '#gmap-basic-marker',
    					lat: -12.043333,
    					lng: -77.028333,
    					markers: [{
    						lat: -12.043333,
    						lng: -77.028333,
    						infoWindow: {
    							content: '<p>Basic</p>'
    						}
    					}]
    				});
    
    				map.addMarker({
    					lat: -12.043333,
    					lng: -77.028333,
    					infoWindow: {
    						content: '<p>Example</p>'
    					}
    				});
    			};	

    Anywhere in there?

    Thanks in advance!


    #10023458

    Support2
    Keymaster

    Hello,

    With a custom code using the “geocode” it’s possible.
    Here is the needed code:

    var initBasicWithMarkers = function() {
    	var map = new GMaps({
    		div: '#gmap-basic-marker',
    		lat: 0,
    		lng: 0,
    		markers: [{
    			lat: 0,
    			lng: 0,
    			infoWindow: {
    				content: '<p>Basic</p>'
    			}
    		}]
    	});
    
    	GMaps.geocode({
    	  address: "Nova York, 1005",
    	  callback: function(results, status) {
    	    if (status == 'OK') {
    	      var latlng = results[0].geometry.location;
    	      map.fitBounds(results[0].geometry.viewport);
    	      map.addMarker({
    	        lat: latlng.lat(),
    	        lng: latlng.lng(),
    	        infoWindow: {
    				content: '<p>Example</p>'
    			}
    	      });
    	    }
    	  }
    	});
    };

    Please, try that and let me know if you need further assistance.

    Kind Regards,

    Rodrigo.


    • This reply was modified 1 week, 2 days ago by  Support2.
    #10023467

    simplyjessica
    Participant
    This reply has been marked as private.
    #10023470

    Support2
    Keymaster
    This reply has been marked as private.
    #10023476

    simplyjessica
    Participant

    Who would have known… enabled and fixed! Thanks!!


    #10023482

    Support2
    Keymaster

    Hello,

    Great that resolved your issue 🙂

    If you need further assistance, please contact us.

    Kind Regards,

    Rodrigo.


Viewing 6 posts - 1 through 6 (of 6 total)