AS3 Get latitude and longitude from a bracketed string


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. var latLngStr:String = "(51.559340379647914, -0.2835899591445923)";
  2. trace(latLngStr);
  3.  
  4. var lat:Number = Number(latLngStr.substring(1, latLngStr.length-1).split(",")[0]);
  5. trace(lat);
  6.  
  7. var lng:Number = Number(latLngStr.substring(1, latLngStr.length-1).split(",")[1]);
  8. trace(lng);
  9.  
  10. // OUTPUT
  11. // (51.559340379647914, -0.2835899591445923)
  12. // 51.559340379647914
  13. // -0.2835899591445923

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.