最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Adding Markers to Google Maps v3 After Map Created - Stack Overflow

programmeradmin1浏览0评论

I'm relatively new with using Google Maps API. Right now I am working on a project where a user can select various search filters and see results automatically show up on the map without reloading the page. My approach thus far has been to create a Javascript object with controls the map so that I could manipulate pieces of it as I wish (ie, centerMap(), addMarker(), clearMap(), etc). I developed several proof-of-concept pieces before beginning this phase of the project.

Right now I am at the point where I have a custom JS object which controls my GMap. The GMap is drawn correctly, the zoom and center are fine. Next I try to run a function which adds a Marker to the map. I'm guessing it's possible to add markers after a map has been generated and I'm simply making a mistake somewhere. Below is my code as it exists. I'm wondering if anybody can shed some light as to why my marker isn't showing up...

Any and all help is greatly appreciated!

Code:

Thanks in advance!! Dima

I'm relatively new with using Google Maps API. Right now I am working on a project where a user can select various search filters and see results automatically show up on the map without reloading the page. My approach thus far has been to create a Javascript object with controls the map so that I could manipulate pieces of it as I wish (ie, centerMap(), addMarker(), clearMap(), etc). I developed several proof-of-concept pieces before beginning this phase of the project.

Right now I am at the point where I have a custom JS object which controls my GMap. The GMap is drawn correctly, the zoom and center are fine. Next I try to run a function which adds a Marker to the map. I'm guessing it's possible to add markers after a map has been generated and I'm simply making a mistake somewhere. Below is my code as it exists. I'm wondering if anybody can shed some light as to why my marker isn't showing up...

Any and all help is greatly appreciated!

Code: http://pastebin./1ZzH9zHk

Thanks in advance!! Dima

Share Improve this question asked Jun 13, 2011 at 19:59 DimaDima 211 silver badge2 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

In your code, shouldn't

var map = new google.maps.Map($('map_canvas'), myOptions);

be

this.map = new google.maps.Map($('map_canvas'), myOptions);
发布评论

评论列表(0)

  1. 暂无评论