开发者

Parse GoogleMarker Coordinates i.e Lat and Long

开发者 https://www.devze.com 2022-12-28 22:30 出处:网络
Hey I am I receiving a string values as such \"(53.32000501118541, -6.223390102386475)\" How can I parse this string to seperate the 2 values and remove the \"(\" 开发者_如何学Pythonand \")\"

Hey I am I receiving a string values as such "(53.32000501118541, -6.223390102386475)"

How can I parse this string to seperate the 2 values and remove the "(" 开发者_如何学Pythonand ")"

Cheers


You could do a simple replace of the brackets and then split by the comma.

String[] coords = "(53.32000501118541,-6.223390102386475)"
.Replace("(",String.Empty).Replace(")",String.Empty).Split(',');

This will give you a string array containing the 2 values you want.

coords[0] will == "53.32000501118541"
coords[1] will == "-6.223390102386475"


I assume you get a GLatLng value and you would like to extract lat and lng. You can use the lat() and lng() functions to do that, without parsing and extracting data from the string.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号