1
votes

I have on my site a section where it displays a map based on Longitude and Latitude coordinates. How exactly can I change or get the number/coordinates of a another state,city, or location ? I tried typing in on Google "Latitude and Longitude of New York" and got the site http://www.latlong.net/

It seemed like the coordinates would work from the website,

For example New York City is Latitude : 40.714353 Longitude: -74.005973

I put them in into my div below but they did not show anything up on the map. If you look below the default coordinates are for California and work just fine. Why is this?

<div
 class="map"
 data-latitude="37,773606"
 data-longtitude="-122,490382"
></div>

Here is my Google Position settings

 // Get map position
            var $map = $('#contact .map');
            var latitude = parseFloat($map.data('latitude').replace(',', '.'));
            var longtitude = parseFloat($map.data('longtitude').replace(',', '.'));
            var center = new google.maps.LatLng(latitude - 0.003105999999997721, longtitude);

            // Render map
            var map = new google.maps.Map($map[0], {
                zoom: 16,
                scrollWheel: false,
                center: center,

                mapTypeId: google.maps.MapTypeId.ROADMAP,
                mapTypeControl: false,
                panControlOptions: {
                    position: google.maps.ControlPosition.LEFT_CENTER
                },
                zoomControlOptions: {
                    position: google.maps.ControlPosition.LEFT_CENTER
                },
                scaleControlOptions: {
                    position: google.maps.ControlPosition.LEFT_CENTER
                }
            });
1
are you getting any errors in the console? - wirey00
I should have put that in there, thanks for reminding. No errors to report! - Miura-shi
what does it means "I put them in into my div below but they did not show anything up on the map" ? - user160820
@user160820 he's storing his long/lat inside the data attributes of his div - wirey00
@wirey yes, I have seen this, but the statement that did not show any thing is very brod. If his functions map-container DIV, if may API with right attribute is included, if JQuery is really included, if the attributes are really there...... - user160820

1 Answers

2
votes

Try $map.attr('data-longtitude').replace(',', '.'), this should work.