0

Can any one please advice me, that, i need to generate an array dynamically for google map... I have a lat and long values from my Database. here i would like to built an array with those values like...the below one.

var store_locations = new Array();
store_locations = [ 
     new google.maps.LatLng(39.112456,-84.574779),
     new google.maps.LatLng(39.314153,-84.261379),
     new google.maps.LatLng(39.197099,-84.667579),
     new google.maps.LatLng(39.16836,-84.479381)
   ];

The inner part of the square bracket should be dynamic. please advice.

2 Answers 2

2

you can use array.push in your cycle

store_locations.push(new google.maps.LatLng(39.112456,-84.574779));
Sign up to request clarification or add additional context in comments.

Comments

1

You can easily do this by pushing new elements to the array:

var store_locations = new Array();
store_locations.push(new google.maps.LatLng(39.112456,-84.574779));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.