Google Maps - JavaScript, marker is not displaying for a house

Posted on 2012-09-08
Medium Priority
Last Modified: 2012-09-08
I have been given the following code from a client, but it needs some changing but I am not sure how to do it since I rarely use JavaScript.

The code receives a lat & lng of a house, and then finds the schools in that local area.

The map should display both the markers for the house with a different icon image and then the markers for the schools within the radius.

At the moment only the schools are showing, hoping someone can inform me of what I need to add to show the property marker?

   <script type="text/javascript">
      var map;
      var infowindow;

      function initialize() {
        var pyrmont = new google.maps.LatLng({address:latitude}, {address:longitude});

        map = new google.maps.Map(document.getElementById('map'), {
          mapTypeId: google.maps.MapTypeId.ROADMAP,
          center: pyrmont,
          zoom: 15

        var request = {
          location: pyrmont,
          radius: 5000,
          types: ['school']
        infowindow = new google.maps.InfoWindow();
        var service = new google.maps.places.PlacesService(map);
        service.search(request, callback);

      function callback(results, status) {
        if (status == google.maps.places.PlacesServiceStatus.OK) {
          for (var i = 0; i < results.length; i++) {

      function createMarker(place) {
        var placeLoc = place.geometry.location;
        var marker = new google.maps.Marker({
          map: map,
          position: place.geometry.location

        google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map, this);

      google.maps.event.addDomListener(window, 'load', initialize);

Open in new window

Question by:dchid
LVL 25

Accepted Solution

lwadwell earned 2000 total points
ID: 38379230
Assuming that the
    var pyrmont = new google.maps.LatLng({address:latitude}, {address:longitude});
defined the location for the house you want to mark ... after the map definition (map = new map...) add
        var marker = new google.maps.Marker({
            position: pyrmont, 
            map: map,
            icon: 'markers/bighouse.png'

Open in new window

The 'bighouse is a reference to a custom marker I downloaded from http://mapicons.nicolasmollet.com/markers/offices/real-estate/house/ there are lots of different markers available there.  The reference is like a img reference.

Author Closing Comment

ID: 38379252
Perfect. Thank you very much, only one more JavaScript thing to do related to this - but will post that in a separate question later.


Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question