Created
February 4, 2018 16:30
-
-
Save albaqawi/62c36de64c3e51b21edceb1f8b78fd4d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| function initialize(rooms) { | |
| var location = { lat: 99.99, lng: 99.99 } | |
| if (rooms.length > 0) { | |
| location = { lat: rooms[0].latitude, lng: rooms[0].longitude } | |
| } | |
| var map = new google.maps.Map(document.getElementById('map'),{ | |
| center: location, | |
| zoom: 12 | |
| }); | |
| var marker, inforwindow, windowContent; | |
| rooms.forEach(function(room) { | |
| marker = new google.maps.Marker({ | |
| position: {lat: room.latitude, lng: room.longitude}, | |
| map: map | |
| }); | |
| windowContent = "<div class='map_price'>SR " + room.price + "</div>"; | |
| windowContent += "<a href='http://localhost:3000/rooms/" + room.id + "'>" + room.listing_name + "</a>" | |
| inforwindow = new google.maps.InfoWindow({ | |
| content: windowContent | |
| }); | |
| inforwindow.open(map, marker); | |
| }) | |
| } | |
| google.maps.event.addDomListener(window, 'load', function() { | |
| initialize(<%= raw @arrRooms.to_json %>) | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment