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

Posted on 2012-09-08
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);, 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() {
, this);

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

Open in new window

Question by:dchid
    LVL 25

    Accepted Solution

    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 there are lots of different markers available there.  The reference is like a img reference.

    Author Closing Comment

    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

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Suggested Solutions

    Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
    Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
    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…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now